Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
860695f2 by Philipp Hörist at 2025-01-16T17:57:39+01:00
fix: Moderation: Parse moderation messages correctly
Fixes #164
- - - - -
2 changed files:
- nbxmpp/modules/muc/moderation.py
- + test/unit/test_moderation.py
Changes:
=====================================
nbxmpp/modules/muc/moderation.py
=====================================
@@ -88,7 +88,7 @@ class Moderation(BaseModule):
stamp = _parse_moderation_timestamp(retract, is_tombstone, properties)
- moderated = stanza.getTag(
+ moderated = retract.getTag(
'moderated', namespace=Namespace.MESSAGE_MODERATE_1)
if moderated is None:
return
=====================================
test/unit/test_moderation.py
=====================================
@@ -0,0 +1,33 @@
+import datetime
+from test.lib.util import StanzaHandlerTest
+
+from nbxmpp import Message
+from nbxmpp.modules.muc.moderation import Moderation
+from nbxmpp.protocol import JID
+from nbxmpp.structs import MessageProperties
+
+
+class TestModeration(StanzaHandlerTest):
+ def test_parse_moderation_message(self):
+ xml = '''
+ <message type="groupchat" id='retraction-id-1'
from='[email protected]' to="[email protected]/macbeth">
+ <retract id="stanza-id-1" xmlns='urn:xmpp:message-retract:1'>
+ <moderated by='[email protected]/macbeth'
xmlns='urn:xmpp:message-moderate:1'>
+ <occupant-id xmlns="urn:xmpp:occupant-id:0"
id="dd72603deec90a38ba552f7c68cbcc61bca202cd" />
+ </moderated>
+ <reason>Some Reason</reason>
+ </retract>
+ </message>
+ '''
+
+ props = MessageProperties('mockjid')
+ message = Message(node=xml)
+ Moderation._process_moderation_1_message(None, None, message, props)
+
+ assert props.moderation is not None
+ self.assertEqual(props.moderation.stanza_id, 'stanza-id-1')
+ self.assertEqual(props.moderation.by,
JID.from_string('[email protected]/macbeth'))
+ self.assertEqual(props.moderation.reason, 'Some Reason')
+ self.assertIsInstance(props.moderation.stamp, datetime.datetime)
+ self.assertFalse(props.moderation.is_tombstone)
+ self.assertEqual(props.moderation.occupant_id,
'dd72603deec90a38ba552f7c68cbcc61bca202cd')
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/860695f225b2c2f818b48c6f5bb97324fa3a1918
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/860695f225b2c2f818b48c6f5bb97324fa3a1918
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]