From 51c0a05ac9b9fb7ad000cf98dea81599a57f2369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 17 Nov 2017 22:05:02 +0100 Subject: [PATCH] Parse from jid correctly --- gajim/common/message_archiving.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gajim/common/message_archiving.py b/gajim/common/message_archiving.py index 6a18d9f0e..5b57df790 100644 --- a/gajim/common/message_archiving.py +++ b/gajim/common/message_archiving.py @@ -117,6 +117,15 @@ class ConnectionArchive313: raise InvalidMamIQ return fin, set_ + def parse_from_jid(self, stanza): + jid = stanza.getFrom() + if jid is None: + # No from means, iq from our own archive + jid = self.get_own_jid().getStripped() + else: + jid = jid.getStripped() + return jid + def _result_finished(self, conn, stanza, query_id, start_date, groupchat): try: fin, set_ = self.parse_iq(stanza, query_id) @@ -128,13 +137,13 @@ class ConnectionArchive313: log.info('End of MAM query, no items retrieved') return - jid = str(stanza.getFrom()) + jid = self.parse_from_jid(stanza) complete = fin.getAttr('complete') app.logger.set_archive_timestamp(jid, last_mam_id=last) if complete != 'true': self.mam_query_ids.remove(query_id) query_id = self.get_query_id() - query = self.get_archive_query(query_id, after=last) + query = self.get_archive_query(query_id, jid=jid, after=last) self._send_archive_query(query, query_id, groupchat=groupchat) else: self.mam_query_ids.remove(query_id) @@ -153,7 +162,7 @@ class ConnectionArchive313: return self.mam_query_ids.remove(query_id) - jid = str(stanza.getFrom()) + jid = self.parse_from_jid(stanza) if start_date: timestamp = start_date.timestamp() else: