summaryrefslogtreecommitdiff
path: root/poezio/multiuserchat.py
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-08-11 23:09:51 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commit4818210a6373261dcc122bb3c699b303ee5bd12f (patch)
tree611cf45fc9f14b5be45d237b2db15b510ba0a19a /poezio/multiuserchat.py
parentc5ef5b0421d8fd80a00497f8529bff6304615fbe (diff)
downloadpoezio-4818210a6373261dcc122bb3c699b303ee5bd12f.tar.gz
poezio-4818210a6373261dcc122bb3c699b303ee5bd12f.tar.bz2
poezio-4818210a6373261dcc122bb3c699b303ee5bd12f.tar.xz
poezio-4818210a6373261dcc122bb3c699b303ee5bd12f.zip
Disabled the history of MUC(from 0045) if the MUC supports MAM.
Diffstat (limited to 'poezio/multiuserchat.py')
-rw-r--r--poezio/multiuserchat.py32
1 files changed, 22 insertions, 10 deletions
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):