diff --git a/src/common/connection.py b/src/common/connection.py index 4f8fdf977..b49149a08 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1199,7 +1199,7 @@ class Connection(ConnectionHandlers): msgenc = '' if session: - fjid = str(session.jid) + fjid = session.get_to() if keyID and self.USE_GPG: xhtml = None diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index d5a5ec9e7..51a12b488 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -54,6 +54,7 @@ class StanzaSession(object): self.conn = conn self.jid = jid self.type = type_ + self.resource = None if thread_id: self.received_thread_id = True @@ -75,6 +76,12 @@ class StanzaSession(object): def is_loggable(self): return self.loggable and gajim.config.should_log(self.conn.name, self.jid) + def get_to(self): + to = str(self.jid) + if self.resource: + to += '/' + self.resource + return to + def remove_events(self, types): ''' Remove events associated with this session from the queue. @@ -107,7 +114,7 @@ class StanzaSession(object): if self.thread_id: msg.NT.thread = self.thread_id - msg.setAttr('to', self.jid) + msg.setAttr('to', self.get_to()) self.conn.send_stanza(msg) if isinstance(msg, xmpp.Message): diff --git a/src/session.py b/src/session.py index 6f5e0627c..f68d7c2dc 100644 --- a/src/session.py +++ b/src/session.py @@ -86,6 +86,10 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): '''dispatch a received stanza''' msg_type = msg.getType() subject = msg.getSubject() + if self.jid != full_jid_with_resource: + self.resource = gajim.get_nick_from_fjid(full_jid_with_resource) + if self.control: + self.control.resource = self.resource if not msg_type or msg_type not in ('chat', 'groupchat', 'error'): msg_type = 'normal'