# HG changeset patch # User souliane # Date 1409685239 -7200 # Node ID 3d8e8f693576ef046c274f18252fbe39507bb65a # Parent 85699d18921f4d1c7ec9e005e13a42524316a53c browser_side: avoid some confusions between jid object 1. as an instance of JID or 2. as a str diff -r 85699d18921f -r 3d8e8f693576 src/browser/sat_browser/contact.py --- a/src/browser/sat_browser/contact.py Tue Sep 02 21:08:59 2014 +0200 +++ b/src/browser/sat_browser/contact.py Tue Sep 02 21:13:59 2014 +0200 @@ -203,6 +203,7 @@ @param jid (str): JID of the contact @param name (str): optional name of the contact """ + assert(isinstance(jid, str)) if jid in self.contacts: return index = 0 diff -r 85699d18921f -r 3d8e8f693576 src/browser/sat_browser/panels.py --- a/src/browser/sat_browser/panels.py Tue Sep 02 21:08:59 2014 +0200 +++ b/src/browser/sat_browser/panels.py Tue Sep 02 21:13:59 2014 +0200 @@ -1253,12 +1253,12 @@ day_format = "%A, %d %b %Y" previous_day = datetime.now().strftime(day_format) for line in history: - timestamp, from_jid, to_jid, message, mess_type, extra = line + timestamp, from_jid_s, to_jid_s, message, mess_type, extra = line message_day = datetime.fromtimestamp(float(timestamp or time())).strftime(day_format) if previous_day != message_day: self.printInfo("* " + message_day) previous_day = message_day - self.printMessage(from_jid, message, extra, timestamp) + self.printMessage(jid.JID(from_jid_s), message, extra, timestamp) self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, size, True) def printInfo(self, msg, type_='normal', link_cb=None): @@ -1285,9 +1285,8 @@ def printMessage(self, from_jid, msg, extra, timestamp=None): """Print message in chat window. Must be implemented by child class""" - _jid = jid.JID(from_jid) - nick = _jid.node if self.type == 'one2one' else _jid.resource - mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare # mymess = True if message comes from local user + nick = from_jid.node if self.type == 'one2one' else from_jid.resource + mymess = from_jid.resource == self.nick if self.type == "group" else from_jid.bare == self.host.whoami.bare # mymess = True if message comes from local user if msg.startswith('/me '): self.printInfo('* %s %s' % (nick, msg[4:]), type_='me') return