remove acfactory.get_chat() in favour of account.create_chat(account2) directly working.

This commit is contained in:
holger krekel
2020-06-08 17:19:21 +02:00
parent 1083cab972
commit 3a85b671a1
5 changed files with 74 additions and 21 deletions

View File

@@ -328,16 +328,26 @@ class Chat(object):
# ------ group management API ------------------------------
def _port_contact(self, contact):
if contact.account != self.account:
contact = self.account.create_contact(contact.addr, contact.display_name)
return contact
def add_contact(self, contact):
""" add a contact to this chat.
If the contact is from another account create a new
contact and add it to the group.
:params: contact object.
:raises ValueError: if contact could not be added
:returns: None
"""
contact = self._port_contact(contact)
ret = lib.dc_add_contact_to_chat(self.account._dc_context, self.id, contact.id)
if ret != 1:
raise ValueError("could not add contact {!r} to chat".format(contact))
return contact
def remove_contact(self, contact):
""" remove a contact from this chat.
@@ -346,6 +356,7 @@ class Chat(object):
:raises ValueError: if contact could not be removed
:returns: None
"""
contact = self._port_contact(contact)
ret = lib.dc_remove_contact_from_chat(self.account._dc_context, self.id, contact.id)
if ret != 1:
raise ValueError("could not remove contact {!r} from chat".format(contact))