diff options
author | Daniel Brötzmann <mailtrash@posteo.de> | 2020-07-03 11:25:47 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-07-07 23:42:04 +0300 |
commit | 144c05fc34519da1de32c8e139632e01f42bfebc (patch) | |
tree | 3d28d2eb07b6a5a5d3993782565956af2563dc41 | |
parent | b045c2a70c45e8a47b4a42f237a4ef80bcadbb8d (diff) |
Blocking: Add XEP-0377 Spam Reporting
-rw-r--r-- | nbxmpp/modules/blocking.py | 8 | ||||
-rw-r--r-- | nbxmpp/namespaces.py | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/nbxmpp/modules/blocking.py b/nbxmpp/modules/blocking.py index 1f55e4f..8d62274 100644 --- a/nbxmpp/modules/blocking.py +++ b/nbxmpp/modules/blocking.py @@ -56,12 +56,16 @@ class Blocking(BaseModule): return BlockingListResult(blocking_list=blocked) @call_on_response('_default_response') - def block(self, jids): + def block(self, jids, report=None): self._log.info('Block: %s', jids) iq = Iq('set', Namespace.BLOCKING) query = iq.setQuery(name='block') for jid in jids: - query.addChild(name='item', attrs={'jid': jid}) + item = query.addChild(name='item', attrs={'jid': jid}) + if report in ('spam', 'abuse'): + action = item.addChild(name='report', + namespace=Namespace.REPORTING) + action.setTag(report) return iq @call_on_response('_default_response') diff --git a/nbxmpp/namespaces.py b/nbxmpp/namespaces.py index e30526f..b97dfd0 100644 --- a/nbxmpp/namespaces.py +++ b/nbxmpp/namespaces.py @@ -128,6 +128,7 @@ class _Namespaces: RECEIPTS: str = 'urn:xmpp:receipts' REGISTER: str = 'jabber:iq:register' REGISTER_FEATURE: str = 'http://jabber.org/features/iq-register' + REPORTING: str = 'urn:xmpp:reporting:0' ROSTER: str = 'jabber:iq:roster' ROSTERNOTES: str = 'storage:rosternotes' ROSTERX: str = 'http://jabber.org/protocol/rosterx' |