From bc58c5a045f627246e69129857666c50c5a509f9 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 12 Dec 2020 14:33:15 +0100 Subject: XEP-0425: Fix plugin registration, and add element --- slixmpp/plugins/xep_0425/moderation.py | 11 +++++++++++ slixmpp/plugins/xep_0425/stanza.py | 1 + 2 files changed, 12 insertions(+) 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) -- cgit v1.2.3