From 4818210a6373261dcc122bb3c699b303ee5bd12f Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Sun, 11 Aug 2019 23:09:51 +0530 Subject: Disabled the history of MUC(from 0045) if the MUC supports MAM. --- poezio/multiuserchat.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'poezio/multiuserchat.py') diff --git a/poezio/multiuserchat.py b/poezio/multiuserchat.py index a58883c6..ee596a0f 100644 --- a/poezio/multiuserchat.py +++ b/poezio/multiuserchat.py @@ -13,6 +13,7 @@ slix plugin from xml.etree import cElementTree as ET from poezio.common import safeJID +from poezio import mam from slixmpp import JID from slixmpp.exceptions import IqError, IqTimeout import logging @@ -118,16 +119,27 @@ def join_groupchat(core, passelement = ET.Element('password') passelement.text = passwd x.append(passelement) - if seconds is not None: - history = ET.Element('{http://jabber.org/protocol/muc}history') - history.attrib['seconds'] = str(seconds) - x.append(history) - stanza.append(x) - core.events.trigger('joining_muc', stanza) - to = stanza["to"] - stanza.send() - xmpp.plugin['xep_0045'].rooms[jid] = {} - xmpp.plugin['xep_0045'].our_nicks[jid] = to.resource + def on_disco(iq): + if 'urn:xmpp:mam:2' in iq['disco_info'].get_features(): + history = ET.Element('{http://jabber.org/protocol/muc}history') + history.attrib['seconds'] = str(0) + x.append(history) + mam.mam_scroll(core.tabs.current_tab) + elif seconds is not None: + history = ET.Element('{http://jabber.org/protocol/muc}history') + history.attrib['seconds'] = str(seconds) + x.append(history) + stanza.append(x) + core.events.trigger('joining_muc', stanza) + to = stanza["to"] + stanza.send() + xmpp.plugin['xep_0045'].rooms[jid] = {} + xmpp.plugin['xep_0045'].our_nicks[jid] = to.resource + + try: + xmpp.plugin['xep_0030'].get_info(jid=jid, callback=on_disco) + except (IqError, IqTimeout): + return core.information('Failed to retrieve messages', 'Error') def leave_groupchat(xmpp, jid, own_nick, msg): -- cgit v1.2.3