changeset 323692ada574 in /home/hg/repos/gajim

author: Yann Leboulanger <aste...@lagaule.org>
branches: gajim_0.16
details:http://hg.gajim.org/gajim?cmd=changeset;node=323692ada574
description: don't create a new session when we get an error message in a pm. 
Fixes #7435

diffstat:

 src/common/connection_handlers.py        |  11 +++++++++++
 src/common/connection_handlers_events.py |  13 +++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diffs (44 lines):

diff -r 6dfdc6f2fb16 -r 323692ada574 src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Tue Aug 27 15:49:08 2013 +0400
+++ b/src/common/connection_handlers.py Tue Aug 27 17:24:41 2013 +0200
@@ -1367,6 +1367,17 @@
         else:
             return None
 
+    def get_latest_session(self, jid):
+        """
+        Get the session that we last sent a message to
+        """
+        if jid not in self.sessions:
+            return None
+        sessions = self.sessions[jid].values()
+        if not sessions:
+            return None
+        return sorted(sessions, key=operator.attrgetter('last_send'))[-1]
+
     def find_controlless_session(self, jid, resource=None):
         """
         Find an active session that doesn't have a control attached
diff -r 6dfdc6f2fb16 -r 323692ada574 src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py  Tue Aug 27 15:49:08 2013 +0400
+++ b/src/common/connection_handlers_events.py  Tue Aug 27 17:24:41 2013 +0200
@@ -1109,8 +1109,17 @@
 
         self.session = None
         if self.mtype != 'groupchat':
-            self.session = self.conn.get_or_create_session(self.fjid,
-                self.thread_id)
+            if gajim.interface.is_pm_contact(self.fjid, account) and \
+            self.mtype == 'error':
+                self.session = self.conn.find_session(self.fjid, 
self.thread_id)
+                if not self.session:
+                    self.session = self.conn.get_latest_session(self.fjid)
+                if not self.session:
+                    self.session = self.conn.make_new_session(self.fjid,
+                        self.thread_id, type_='pm')
+            else:
+                self.session = self.conn.get_or_create_session(self.fjid,
+                    self.thread_id)
 
             if self.thread_id and not self.session.received_thread_id:
                 self.session.received_thread_id = True
_______________________________________________
Commits mailing list
Commits@gajim.org
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to