diff options
author | Link Mauve <linkmauve@linkmauve.fr> | 2020-12-12 14:45:49 +0100 |
---|---|---|
committer | Link Mauve <linkmauve@linkmauve.fr> | 2020-12-12 14:45:49 +0100 |
commit | 71888b24a6d88c0396a08f5c8a28a79aa28e3669 (patch) | |
tree | 0d264a6858ccadcf58f7e10233cdf8bd0078b29a | |
parent | d6be776640ca4d13a84c88be2e22e7c67d1c9c04 (diff) | |
parent | 3b00c56bdc85db189029bd30e14e0d53e15ff497 (diff) | |
download | slixmpp-71888b24a6d88c0396a08f5c8a28a79aa28e3669.tar.gz slixmpp-71888b24a6d88c0396a08f5c8a28a79aa28e3669.tar.bz2 slixmpp-71888b24a6d88c0396a08f5c8a28a79aa28e3669.tar.xz slixmpp-71888b24a6d88c0396a08f5c8a28a79aa28e3669.zip |
Merge branch 'retraction-event' into 'master'
XEP-0424: Add an event for message retraction
See merge request poezio/slixmpp!87
-rw-r--r-- | itests/test_retract.py | 2 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0424/retraction.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/itests/test_retract.py b/itests/test_retract.py index 55f79fa9..3a554006 100644 --- a/itests/test_retract.py +++ b/itests/test_retract.py @@ -22,7 +22,7 @@ class TestRetract(SlixIntegration): id='toto', fallback_text='Twas a mistake', ) - msg = await self.clients[1].wait_until('message') + msg = await self.clients[1].wait_until('message_retract') self.assertEqual(msg['apply_to']['id'], 'toto') self.assertTrue(msg['apply_to']['retract']) diff --git a/slixmpp/plugins/xep_0424/retraction.py b/slixmpp/plugins/xep_0424/retraction.py index d3461d66..09e3adee 100644 --- a/slixmpp/plugins/xep_0424/retraction.py +++ b/slixmpp/plugins/xep_0424/retraction.py @@ -9,6 +9,8 @@ from typing import Optional from slixmpp import JID, Message from slixmpp.exceptions import IqError, IqTimeout +from slixmpp.xmlstream.matcher import StanzaPath +from slixmpp.xmlstream.handler import Callback from slixmpp.plugins import BasePlugin from slixmpp.plugins.xep_0424 import stanza @@ -30,6 +32,11 @@ class XEP_0424(BasePlugin): def plugin_init(self) -> None: stanza.register_plugins() + self.xmpp.register_handler(Callback( + "Message Retracted", + StanzaPath("message/apply_to/retract"), + self._handle_retract_message, + )) def session_bind(self, jid): self.xmpp.plugin['xep_0030'].add_feature(feature=stanza.NS) @@ -37,6 +44,10 @@ class XEP_0424(BasePlugin): def plugin_end(self): self.xmpp.plugin['xep_0030'].del_feature(feature=stanza.NS) + def _handle_retract_message(self, message: Message): + if message['type'] != 'groupchat': + self.xmpp.event('message_retract', message) + def send_retraction(self, mto: JID, id: str, mtype: str = 'chat', include_fallback: bool = True, fallback_text: Optional[str] = None, *, |