mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 06:26:30 +03:00
api(deltachat-rpc-client): accept Account as Account.create_contact() argument
This commit is contained in:
@@ -115,7 +115,7 @@ class Account:
|
|||||||
self.start_io()
|
self.start_io()
|
||||||
self.wait_for_event(EventType.IMAP_INBOX_IDLE)
|
self.wait_for_event(EventType.IMAP_INBOX_IDLE)
|
||||||
|
|
||||||
def create_contact(self, obj: Union[int, str, Contact], name: Optional[str] = None) -> Contact:
|
def create_contact(self, obj: Union[int, str, Contact, "Account"], name: Optional[str] = None) -> Contact:
|
||||||
"""Create a new Contact or return an existing one.
|
"""Create a new Contact or return an existing one.
|
||||||
|
|
||||||
Calling this method will always result in the same
|
Calling this method will always result in the same
|
||||||
@@ -123,9 +123,15 @@ class Account:
|
|||||||
with that e-mail address, it is unblocked and its display
|
with that e-mail address, it is unblocked and its display
|
||||||
name is updated if specified.
|
name is updated if specified.
|
||||||
|
|
||||||
:param obj: email-address or contact id.
|
:param obj: email-address, contact id or account.
|
||||||
:param name: (optional) display name for this contact.
|
:param name: (optional) display name for this contact.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(obj, Account):
|
||||||
|
vcard = obj.self_contact.make_vcard()
|
||||||
|
[contact] = self.import_vcard(vcard)
|
||||||
|
if name:
|
||||||
|
contact.set_name(name)
|
||||||
|
return contact
|
||||||
if isinstance(obj, int):
|
if isinstance(obj, int):
|
||||||
obj = Contact(self, obj)
|
obj = Contact(self, obj)
|
||||||
if isinstance(obj, Contact):
|
if isinstance(obj, Contact):
|
||||||
@@ -146,9 +152,8 @@ class Account:
|
|||||||
return [Contact(self, contact_id) for contact_id in contact_ids]
|
return [Contact(self, contact_id) for contact_id in contact_ids]
|
||||||
|
|
||||||
def create_chat(self, account: "Account") -> Chat:
|
def create_chat(self, account: "Account") -> Chat:
|
||||||
vcard = account.self_contact.make_vcard()
|
"""Create a 1:1 chat with another account."""
|
||||||
[contact] = self.import_vcard(vcard)
|
return self.create_contact(account).create_chat()
|
||||||
return contact.create_chat()
|
|
||||||
|
|
||||||
def get_device_chat(self) -> Chat:
|
def get_device_chat(self) -> Chat:
|
||||||
"""Return device chat."""
|
"""Return device chat."""
|
||||||
|
|||||||
Reference in New Issue
Block a user