diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index 09883f452..173ec8e84 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -51,6 +51,16 @@ class Chat(object): # ------ chat status/metadata API ------------------------------ + def is_group(self): + """ return true if this chat is a group chat. + + :returns: True if chat is a group-chat, false if it's a contact 1:1 chat. + """ + return lib.dc_chat_get_type(self._dc_chat) in ( + const.DC_CHAT_TYPE_GROUP, + const.DC_CHAT_TYPE_VERIFIED_GROUP + ) + def is_deaddrop(self): """ return true if this chat is a deaddrop chat. @@ -129,7 +139,7 @@ class Chat(object): return bool(lib.dc_chat_get_remaining_mute_duration(self.id)) def get_type(self): - """ return type of this chat. + """ (deprecated) return type of this chat. :returns: one of const.DC_CHAT_TYPE_* """ diff --git a/python/tests/test_account.py b/python/tests/test_account.py index c625b94c9..5c5fc8338 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -147,6 +147,9 @@ class TestOfflineChat: str(chat1) repr(chat1) + def test_is_group(self, chat1): + assert not chat1.is_group() + def test_chat_by_id(self, chat1): chat2 = chat1.account.get_chat_by_id(chat1.id) assert chat2 == chat1 @@ -169,6 +172,7 @@ class TestOfflineChat: def test_add_member_event(self, ac1, make_plugin_recorder): chat = ac1.create_group_chat(name="title1") + assert chat.is_group() # promote the chat chat.send_text("hello") contact1 = ac1.create_contact("some1@hello.com", name="some1") @@ -229,6 +233,7 @@ class TestOfflineChat: def test_group_chat_qr(self, acfactory, ac1, verified): ac2 = acfactory.get_configured_offline_account() chat = ac1.create_group_chat(name="title1", verified=verified) + assert chat.is_group() qr = chat.get_join_qr() assert ac2.check_qr(qr).is_ask_verifygroup