From 2b59d299a1144480ce63154bdf173b68877f1bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 19 Mar 2023 10:27:00 +0100 Subject: [PATCH] XEP-0377: Update to latest revision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp/plugins/xep_0377/spam_reporting.py | 3 ++ slixmpp/plugins/xep_0377/stanza.py | 45 +++------------------- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/slixmpp/plugins/xep_0377/spam_reporting.py b/slixmpp/plugins/xep_0377/spam_reporting.py index d6ef6d7e..9569faac 100644 --- a/slixmpp/plugins/xep_0377/spam_reporting.py +++ b/slixmpp/plugins/xep_0377/spam_reporting.py @@ -26,6 +26,9 @@ class XEP_0377(BasePlugin): dependencies = {'xep_0030', 'xep_0191'} stanza = stanza + SPAM = 'urn:xmpp:reporting:spam' + ABUSE = 'urn:xmpp:reporting:abuse' + def plugin_init(self): register_stanza_plugin(Block, stanza.Report) register_stanza_plugin(stanza.Report, stanza.Text) diff --git a/slixmpp/plugins/xep_0377/stanza.py b/slixmpp/plugins/xep_0377/stanza.py index 40058c60..3ae31e32 100644 --- a/slixmpp/plugins/xep_0377/stanza.py +++ b/slixmpp/plugins/xep_0377/stanza.py @@ -13,58 +13,23 @@ class Report(ElementBase): Example sub stanza: :: - + Never came trouble to my house like this. - - Stanza Interface: - :: + The reason attribute is mandatory. - abuse -- Flag the report as abuse - spam -- Flag the report as spam - text -- Add a reason to the report - - Only one or element can be present at once. """ name = "report" - namespace = "urn:xmpp:reporting:0" + namespace = "urn:xmpp:reporting:1" plugin_attrib = "report" - interfaces = ("spam", "abuse", "text") + interfaces = ("text", "reason") sub_interfaces = {'text'} - def _purge_spam(self): - spam = self.xml.findall('{%s}spam' % self.namespace) - for element in spam: - self.xml.remove(element) - - def _purge_abuse(self): - abuse = self.xml.findall('{%s}abuse' % self.namespace) - for element in abuse: - self.xml.remove(element) - - def get_spam(self): - return self.xml.find('{%s}spam' % self.namespace) is not None - - def set_spam(self, value): - self._purge_spam() - if bool(value): - self._purge_abuse() - self.xml.append(ET.Element('{%s}spam' % self.namespace)) - - def get_abuse(self): - return self.xml.find('{%s}abuse' % self.namespace) is not None - - def set_abuse(self, value): - self._purge_abuse() - if bool(value): - self._purge_spam() - self.xml.append(ET.Element('{%s}abuse' % self.namespace)) - class Text(ElementBase): name = "text" plugin_attrib = "text" - namespace = "urn:xmpp:reporting:0" + namespace = "urn:xmpp:reporting:1"