From c45d0f5b279a42488bd90b7524f6d664498ce7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 19 Nov 2017 23:45:03 +0100 Subject: [PATCH] Query MUC archives with the correct namespace --- gajim/common/caps_cache.py | 9 +++++++++ gajim/common/message_archiving.py | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gajim/common/caps_cache.py b/gajim/common/caps_cache.py index 7f2762257..957633f7d 100644 --- a/gajim/common/caps_cache.py +++ b/gajim/common/caps_cache.py @@ -491,3 +491,12 @@ class MucCapsCache: return True except (KeyError, AttributeError): return False + + def get_mam_namespace(self, jid): + try: + if nbxmpp.NS_MAM_2 in self.cache[jid].features: + return nbxmpp.NS_MAM_2 + elif nbxmpp.NS_MAM_1 in self.cache[jid].features: + return nbxmpp.NS_MAM_1 + except (KeyError, AttributeError): + return diff --git a/gajim/common/message_archiving.py b/gajim/common/message_archiving.py index e83033fee..be60c1983 100644 --- a/gajim/common/message_archiving.py +++ b/gajim/common/message_archiving.py @@ -27,6 +27,7 @@ from gajim.common import app from gajim.common import ged from gajim.common.logger import KindConstant, JIDConstant from gajim.common.const import ArchiveState +from gajim.common.caps_cache import muc_caps_cache import gajim.common.connection_handlers_events as ev log = logging.getLogger('gajim.c.message_archiving') @@ -296,7 +297,12 @@ class ConnectionArchive313: def get_archive_query(self, query_id, jid=None, start=None, end=None, with_=None, after=None, max_=30): - namespace = self.archiving_namespace + # Muc archive query? + namespace = muc_caps_cache.get_mam_namespace(jid) + if namespace is None: + # Query to our own archive + namespace = self.archiving_namespace + iq = nbxmpp.Iq('set', to=jid) query = iq.addChild('query', namespace=namespace) form = query.addChild(node=nbxmpp.DataForm(typ='submit'))