xep-0424: update to version 0.4.0

This commit is contained in:
nicoco 2024-03-17 12:20:06 +01:00 committed by mathieui
parent cf3b30120e
commit dd903b1792
5 changed files with 16 additions and 24 deletions

View File

@ -856,7 +856,7 @@
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0424.html"/>
<xmpp:status>complete</xmpp:status>
<xmpp:version>0.3.0</xmpp:version>
<xmpp:version>0.4.0</xmpp:version>
<xmpp:since>1.6.0</xmpp:since>
</xmpp:SupportedXep>
</implements>

View File

@ -4,7 +4,6 @@
# This file is part of Slixmpp.
# See the file LICENSE for copying permission.
from slixmpp.plugins.base import register_plugin
from slixmpp.plugins.xep_0424.stanza import *
from slixmpp.plugins.xep_0424.retraction import XEP_0424
from .retraction import XEP_0424
register_plugin(XEP_0424)

View File

@ -31,7 +31,7 @@ class XEP_0424(BasePlugin):
stanza.register_plugins()
self.xmpp.register_handler(Callback(
"Message Retracted",
StanzaPath("message/apply_to/retract"),
StanzaPath("message/retract"),
self._handle_retract_message,
))
@ -64,7 +64,6 @@ class XEP_0424(BasePlugin):
if include_fallback:
msg['body'] = fallback_text
msg.enable('fallback')
msg['apply_to']['id'] = id
msg['apply_to'].enable('retract')
msg['retract']['id'] = id
msg.enable('store')
msg.send()

View File

@ -8,28 +8,27 @@ from slixmpp.xmlstream import (
ElementBase,
register_stanza_plugin,
)
from slixmpp.plugins.xep_0422.stanza import ApplyTo
from slixmpp.plugins.xep_0359 import OriginID
NS = 'urn:xmpp:message-retract:0'
NS = 'urn:xmpp:message-retract:1'
class Retract(ElementBase):
namespace = NS
name = 'retract'
plugin_attrib = 'retract'
interfaces = {'reason', 'id'}
sub_interfaces = {'reason'}
class Retracted(ElementBase):
namespace = NS
name = 'retracted'
plugin_attrib = 'retracted'
interfaces = {'stamp'}
interfaces = {'stamp', 'id', 'reason'}
sub_interfaces = {'reason'}
def register_plugins():
register_stanza_plugin(ApplyTo, Retract)
register_stanza_plugin(Message, Retract)
register_stanza_plugin(Message, Retracted)
register_stanza_plugin(Retracted, OriginID)

View File

@ -2,38 +2,33 @@ import unittest
from slixmpp import Message
from slixmpp.test import SlixTest
from slixmpp.plugins.xep_0424 import stanza
from slixmpp.plugins.xep_0422 import stanza as astanza
class TestRetraction(SlixTest):
def setUp(self):
astanza.register_plugins()
stanza.register_plugins()
def testRetract(self):
message = Message()
message['apply_to']['id'] = 'some-id'
message['apply_to']['retract']
message['retract']['id'] = 'some-id'
self.check(message, """
<message>
<apply-to xmlns="urn:xmpp:fasten:0" id="some-id">
<retract xmlns="urn:xmpp:message-retract:0"/>
</apply-to>
<retract xmlns="urn:xmpp:message-retract:1" id="some-id"/>
</message>
""", use_values=False)
def testRetracted(self):
message = Message()
message['retracted']['stamp'] = '2019-09-20T23:09:32Z'
message['retracted']['origin_id']['id'] = 'originid'
message['retracted']['id'] = 'originid'
self.check(message, """
<message>
<retracted stamp="2019-09-20T23:09:32Z" xmlns="urn:xmpp:message-retract:0">
<origin-id xmlns="urn:xmpp:sid:0" id="originid"/>
</retracted>
<retracted stamp="2019-09-20T23:09:32Z"
xmlns="urn:xmpp:message-retract:1"
id="originid" />
</message>
""")