diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index 03b052b24..46a743571 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -424,13 +424,33 @@ class Chat(object): :returns: True if archived. """ return lib.dc_chat_get_archived(self._dc_chat) == 1 - + def is_pinned(self): """return True if this chat is pinned. :returns: True if pinned. """ return lib.dc_chat_get_archived(self._dc_chat) == 2 + def archive(self): + """archive the chat. + """ + lib.dc_archive_chat(self._dc_context, self.id, 1) + + def unarchive(self): + """unarchive the chat. + """ + lib.dc_archive_chat(self._dc_context, self.id, 0) + + def pin(self): + """pin the chat. + """ + lib.dc_archive_chat(self._dc_context, self.id, 2) + + def unpin(self): + """unpin the chat. (same as unarchive) + """ + self.unarchive() + def enable_sending_locations(self, seconds): """enable sending locations for this chat. diff --git a/python/tests/test_account.py b/python/tests/test_account.py index f31766e98..c06bde091 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -426,6 +426,17 @@ class TestOfflineChat: chat.remove_contact(contacts[3]) assert len(chat.get_contacts()) == 9 + def test_archive_and_pin_chat(self, ac1): + chat = ac1.create_group_chat(name="title1") + + assert not chat.is_archived() + chat.archive() + assert chat.is_archived() + chat.unarchive() + assert not chat.is_archived() + chat.pin() + assert chat.is_pinned() + class TestOnlineAccount: @pytest.mark.ignored