diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/message.py b/deltachat-rpc-client/src/deltachat_rpc_client/message.py index a52a48b55..6bb5d98f8 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/message.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/message.py @@ -60,6 +60,10 @@ class Message: """Mark the message as seen.""" self._rpc.markseen_msgs(self.account.id, [self.id]) + def exists(self) -> bool: + """Return True if the message exists.""" + return bool(self._rpc.get_existing_msg_ids(self.account.id, [self.id])) + def continue_autocrypt_key_transfer(self, setup_code: str) -> None: """Continue the Autocrypt Setup Message key transfer. diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 007776bc0..d8177eca6 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -993,3 +993,22 @@ def test_background_fetch(acfactory, dc): snapshot = messages[-1].get_snapshot() if snapshot.text == "Hello again!": break + + +def test_message_exists(acfactory): + ac1, ac2 = acfactory.get_online_accounts(2) + chat = ac1.create_chat(ac2) + message1 = chat.send_text("Hello!") + message2 = chat.send_text("Hello again!") + assert message1.exists() + assert message2.exists() + + ac1.delete_messages([message1]) + assert not message1.exists() + assert message2.exists() + + # There is no error when checking if + # the message exists for deleted account. + ac1.remove() + assert not message1.exists() + assert not message2.exists()