summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-12 14:33:15 +0100
committermathieui <mathieui@mathieui.net>2020-12-12 14:33:48 +0100
commitbc58c5a045f627246e69129857666c50c5a509f9 (patch)
treee1ce9f1ffd38fb1027a4abb788cae13ebac787b9
parentd6be776640ca4d13a84c88be2e22e7c67d1c9c04 (diff)
downloadslixmpp-bc58c5a045f627246e69129857666c50c5a509f9.tar.gz
slixmpp-bc58c5a045f627246e69129857666c50c5a509f9.tar.bz2
slixmpp-bc58c5a045f627246e69129857666c50c5a509f9.tar.xz
slixmpp-bc58c5a045f627246e69129857666c50c5a509f9.zip
XEP-0425: Fix plugin registration, and add element
-rw-r--r--slixmpp/plugins/xep_0425/moderation.py11
-rw-r--r--slixmpp/plugins/xep_0425/stanza.py1
2 files changed, 12 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0425/moderation.py b/slixmpp/plugins/xep_0425/moderation.py
index e840d80d..6f67806b 100644
--- a/slixmpp/plugins/xep_0425/moderation.py
+++ b/slixmpp/plugins/xep_0425/moderation.py
@@ -9,6 +9,8 @@ from typing import Optional
from slixmpp import JID, Message
from slixmpp.exceptions import IqError, IqTimeout
+from slixmpp.xmlstream.handler import Callback
+from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0425 import stanza
@@ -24,10 +26,19 @@ class XEP_0425(BasePlugin):
def plugin_init(self) -> None:
stanza.register_plugins()
+ self.xmpp.register_handler(Callback(
+ 'Moderated Message',
+ StanzaPath('message/apply_to/moderated/retract'),
+ self._handle_moderated,
+ ))
def session_bind(self, jid):
self.xmpp.plugin['xep_0030'].add_feature(feature=stanza.NS)
+ def _handle_moderated(self, message: Message):
+ if message['type'] == 'groupchat':
+ self.xmpp.event('moderated_message', message)
+
def plugin_end(self):
self.xmpp.plugin['xep_0030'].del_feature(feature=stanza.NS)
diff --git a/slixmpp/plugins/xep_0425/stanza.py b/slixmpp/plugins/xep_0425/stanza.py
index 9b756953..566b1d09 100644
--- a/slixmpp/plugins/xep_0425/stanza.py
+++ b/slixmpp/plugins/xep_0425/stanza.py
@@ -42,5 +42,6 @@ def register_plugins():
register_stanza_plugin(Message, Moderated)
register_stanza_plugin(ApplyTo, Moderated)
+ register_stanza_plugin(Moderated, Retract)
register_stanza_plugin(Moderated, Retracted)
register_stanza_plugin(Moderated, OccupantId)