From 43c2f2f0abe255796ee74d695ba55f4a20531c0f Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Tue, 21 Nov 2006 20:26:44 +0000
Subject: [PATCH] change resource of incoming event when a resource disconected
 between the moment we get the message and the moment we read it. see #2657

---
 src/common/events.py | 9 +++++++++
 src/gajim.py         | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/src/common/events.py b/src/common/events.py
index 99cd98cfc3..dbadef0335 100644
--- a/src/common/events.py
+++ b/src/common/events.py
@@ -118,6 +118,15 @@ class Events:
 		if gajim.interface.systray_capabilities:
 			gajim.interface.systray.set_img()
 
+	def change_jid(self, account, old_jid, new_jid):
+		if not self._events[account].has_key(old_jid):
+			return
+		if self._events[account].has_key(new_jid):
+			self._events[account][new_jid] += self._events[account][old_jid]
+		else:
+			self._events[account][new_jid] = self._events[account][old_jid]
+		del self._events[account][old_jid]
+
 	def get_nb_events(self, types = [], account = None):
 		return self._get_nb_events(types = types, account = account)
 
diff --git a/src/gajim.py b/src/gajim.py
index ea067cf34e..864ebac1f8 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -1804,6 +1804,8 @@ class Interface:
 				# message and is now higher because the other one is offline
 				if resource and highest_contact.resource == resource and \
 				not self.msg_win_mgr.has_window(jid, account):
+					# remove resource of events too
+					gajim.events.change_jid(account, fjid, jid)
 					resource = None
 					fjid = jid
 				contact = gajim.contacts.get_contact(account, jid, resource)
-- 
GitLab