1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00

add initial group management API and is_promoted()

This commit is contained in:
holger krekel 2018-09-18 19:37:07 +02:00
parent 3015c3c6d7
commit e777b576cb
4 changed files with 77 additions and 12 deletions

View file

@ -14,7 +14,7 @@ from attr import validators as v
import deltachat
from .capi import ffi, lib
from .cutil import as_dc_charpointer, from_dc_charpointer, iter_array_and_unref
from .cutil import as_dc_charpointer, from_dc_charpointer, iter_array
from .chatting import Contact, Chat, Message
@ -117,8 +117,11 @@ class Account(object):
flags |= lib.DC_GCL_VERIFIED_ONLY
if with_self:
flags |= lib.DC_GCL_ADD_SELF
dc_array_t = lib.dc_get_contacts(self._dc_context, flags, query)
return list(iter_array_and_unref(dc_array_t, lambda x: Contact(self._dc_context, x)))
dc_array = ffi.gc(
lib.dc_get_contacts(self._dc_context, flags, query),
lib.dc_array_unref
)
return list(iter_array(dc_array, lambda x: Contact(self._dc_context, x)))
def create_chat_by_contact(self, contact):
""" create or get an existing 1:1 chat object for the specified contact.
@ -144,6 +147,18 @@ class Account(object):
chat_id = lib.dc_create_chat_by_msg_id(self._dc_context, msg_id)
return Chat(self._dc_context, chat_id)
def create_group_chat(self, name, verified=False):
""" create a new group chat object.
Chats are unpromoted until the first message is sent.
:param verified: if true only verified contacts can be added.
:returns: a :class:`Chat` object.
"""
bytes_name = name.encode("utf8")
chat_id = lib.dc_create_group_chat(self._dc_context, verified, bytes_name)
return Chat(self._dc_context, chat_id)
def get_chats(self):
""" return list of chats.