diff src/browser/sat_browser/plugin_sec_otr.py @ 557:d0114855d6d4

browser_side (plugin OTR): fixes missing resource issue: - the problem might still happen but at least: - the session won't be started with a bare JID - if a session with a full JID exists and the user tries to send a message to a bare JID, he will get the big warning added (c.f last changeset)
author souliane <souliane@mailoo.org>
date Tue, 23 Sep 2014 10:53:52 +0200
parents 3aef7c5c7d3a
children 77372641e05d
line wrap: on
line diff
--- a/src/browser/sat_browser/plugin_sec_otr.py	Tue Sep 23 09:32:10 2014 +0200
+++ b/src/browser/sat_browser/plugin_sec_otr.py	Tue Sep 23 10:53:52 2014 +0200
@@ -394,13 +394,16 @@
     def fixResource(self, jid, cb):
         # FIXME: it's dirty, but libervia doesn't manage resources correctly now, refactoring is planed
         if jid.resource:
+            self.last_resources[jid.bare] = jid.resource
             cb(jid)
         elif jid.bare in self.last_resources:
-            jid.resource = self.last_resources[jid.bare]
+            jid.setResource(self.last_resources[jid.bare])
             cb(jid)
         else:
             def gotResource(resource):
-                jid.setResource(resource)
+                if resource:
+                    jid.setResource(resource)
+                    self.last_resources[jid.bare] = jid.resource
                 cb(jid)
             self.host.bridge.call('getLastResource', gotResource, jid.full())