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'))