diff --git a/src/team_bot/bot.py b/src/team_bot/bot.py index ae34960..cca6aa9 100644 --- a/src/team_bot/bot.py +++ b/src/team_bot/bot.py @@ -156,6 +156,7 @@ def ac_incoming_message(self, message: deltachat.Message): else: logging.debug("Ignoring message, just the crew chatting") else: + self.mark_last_messages_read(message.chat) logging.debug("Ignoring message, just the crew chatting") else: @@ -277,3 +278,12 @@ def offboard(self, ex_admin: deltachat.Contact) -> None: relay_group = self.account.get_chat_by_id(mapping[1]) if ex_admin in relay_group.get_contacts(): relay_group.remove_contact(ex_admin) + + def mark_last_messages_read(self, relay_group: deltachat.Chat) -> None: + """Mark the last incoming messages as read for a corresponding relay group. + + :param relay_group: the relay group in which the messages which should marked read were forwarded. + """ + outside_chat = self.get_outside_chat(relay_group.id) + for msg in outside_chat.get_messages(): + msg.mark_seen() diff --git a/tests/test_bot.py b/tests/test_bot.py index b185962..03d3704 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -103,6 +103,7 @@ def test_relay_group_forwarding(relaycrew, outsider): message_from_outsider = bot._evtracker.wait_next_incoming_message() bot_outside_chat = message_from_outsider.chat assert not bot.relayplugin.is_relay_group(bot_outside_chat) + assert message_from_outsider.is_in_fresh() # get relay group user_forwarded_message_from_outsider = user._evtracker.wait_next_incoming_message() @@ -132,6 +133,7 @@ def test_relay_group_forwarding(relaycrew, outsider): user._dc_context, user_relay_group.id, user_direct_reply._dc_msg ) assert sent_id == user_direct_reply.id + assert message_from_outsider.is_in_seen() # check that direct reply was forwarded to outsider outsider_direct_reply = outsider._evtracker.wait_next_incoming_message()