add test and python API for verified group handling/chatting

add msg.is_encrypted() API and check for it from some tests
This commit is contained in:
holger krekel
2019-09-19 20:53:21 +02:00
parent 9f914dd42e
commit ceff85d892
4 changed files with 55 additions and 1 deletions

View File

@@ -231,7 +231,7 @@ class Account(object):
:returns: a :class:`deltachat.chatting.Chat` object.
"""
bytes_name = name.encode("utf8")
chat_id = lib.dc_create_group_chat(self._dc_context, verified, bytes_name)
chat_id = lib.dc_create_group_chat(self._dc_context, int(verified), bytes_name)
return Chat(self, chat_id)
def get_chats(self):
@@ -378,6 +378,15 @@ class Account(object):
raise ValueError("could not join group")
return Chat(self, chat_id)
#
# meta API for start/stop and event based processing
#
def wait_next_incoming_message(self):
""" wait for and return next incoming message. """
ev = self._evlogger.get_matching("DC_EVENT_INCOMING_MSG")
return self.get_message_by_id(ev[2])
def start_threads(self):
""" start IMAP/SMTP threads (and configure account if it hasn't happened).

View File

@@ -109,6 +109,13 @@ class Chat(object):
"""
return not lib.dc_chat_is_unpromoted(self._dc_chat)
def is_verified(self):
""" return True if this chat is a verified group.
:returns: True if chat is verified, False otherwise.
"""
return lib.dc_chat_is_verified(self._dc_chat)
def get_name(self):
""" return name of this chat.

View File

@@ -101,6 +101,10 @@ class Message(object):
""" return True if this message is a setup message. """
return lib.dc_msg_is_setupmessage(self._dc_msg)
def is_encrypted(self):
""" return True if this message was encrypted. """
return bool(lib.dc_msg_get_showpadlock(self._dc_msg))
def get_message_info(self):
""" Return informational text for a single message.