Mark messages as read after someone talked about it in a relay group

fix #15
This commit is contained in:
missytake 2024-08-20 13:42:49 +02:00
parent 9c40e5f3af
commit 3f09be5b25
2 changed files with 12 additions and 0 deletions

View file

@ -156,6 +156,7 @@ class RelayPlugin:
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 @@ class RelayPlugin:
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()

View file

@ -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()