mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
remove acfactory.get_chat() in favour of account.create_chat(account2) directly working.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user