Merge branch 'fix-moderation' into 'master'

XEP-0425: small fix & integration test

See merge request poezio/slixmpp!86
This commit is contained in:
Link Mauve
2020-12-12 14:51:25 +01:00
3 changed files with 78 additions and 0 deletions

View File

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

View File

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