From 6f472cc120142691c6a46ff95cb494b9411ac5c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <forenjunkie@chello.at>
Date: Fri, 29 Sep 2017 12:41:26 +0200
Subject: [PATCH] Set message as read before removing an event

When we receive carbons of a conversation, we remove the events once
we receive a carbon from ourself, because that means we anwered from
another device.

This sets these removed messages also as read in the unread_message
table, so they dont popup on restart.
---
 gajim/session.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gajim/session.py b/gajim/session.py
index 5a44fc260c..afb3b552e4 100644
--- a/gajim/session.py
+++ b/gajim/session.py
@@ -247,6 +247,12 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
             # Its a Carbon Copied Message we sent
             obj.show_in_roster = False
             obj.show_in_systray = False
+            unread_events = app.events.get_events(
+                self.conn.name, fjid, types=['chat'])
+            read_ids = []
+            for msg in unread_events:
+                read_ids.append(msg.msg_log_id)
+            app.logger.set_read_messages(read_ids)
             app.events.remove_events(self.conn.name, fjid, types=['chat'])
             do_event = False
         else:
-- 
GitLab