From 5ef18134055b12a2715d9c62b7005ebe5c912048 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Wed, 17 Jan 2018 23:52:19 +0100
Subject: [PATCH] Fix parsing MAM IQs

prosody includes the supplied queryid in the `<fin>` tag, but this is not XEP compliant.

We set the queryid attr so we can match the MAM Messages to our query.
Thats the only purpose, it is not used to identify the iq result at the end of the query.
For that purpose is the `id` attr on the `<iq>` node.

So dont try to parse `queryid` from the `<fin>` tag.
---
 gajim/common/message_archiving.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gajim/common/message_archiving.py b/gajim/common/message_archiving.py
index be60c19839..f4d3004191 100644
--- a/gajim/common/message_archiving.py
+++ b/gajim/common/message_archiving.py
@@ -96,7 +96,7 @@ class ConnectionArchive313:
         del self.mam_awaiting_disco_result[obj.jid]
 
     @staticmethod
-    def parse_iq(stanza, query_id):
+    def parse_iq(stanza):
         if not nbxmpp.isResultNode(stanza):
             log.error('Error on MAM query: %s', stanza.getError())
             raise InvalidMamIQ
@@ -106,10 +106,6 @@ class ConnectionArchive313:
             log.error('Malformed MAM query result received: %s', stanza)
             raise InvalidMamIQ
 
-        if fin.getAttr('queryid') != query_id:
-            log.error('Result with unknown query id received')
-            raise InvalidMamIQ
-
         set_ = fin.getTag('set', namespace=nbxmpp.NS_RSM)
         if set_ is None:
             log.error(
@@ -129,7 +125,7 @@ class ConnectionArchive313:
 
     def _result_finished(self, conn, stanza, query_id, start_date, groupchat):
         try:
-            fin, set_ = self.parse_iq(stanza, query_id)
+            fin, set_ = self.parse_iq(stanza)
         except InvalidMamIQ:
             return
 
@@ -158,7 +154,7 @@ class ConnectionArchive313:
     def _intervall_result_finished(self, conn, stanza, query_id,
                                    start_date, end_date, event_id):
         try:
-            fin, set_ = self.parse_iq(stanza, query_id)
+            fin, set_ = self.parse_iq(stanza)
         except InvalidMamIQ:
             return
 
@@ -190,7 +186,7 @@ class ConnectionArchive313:
 
     def _received_count(self, conn, stanza, query_id, event_id):
         try:
-            _, set_ = self.parse_iq(stanza, query_id)
+            _, set_ = self.parse_iq(stanza)
         except InvalidMamIQ:
             return
 
-- 
GitLab