Mercurial > prosody-modules
diff mod_spam_reporting/mod_spam_reporting.lua @ 4612:fe24bda72838
mod_spam_reporting: Add support for XEP-0377 0.3
Support 'urn:xmpp:reporting:1', see
https://xmpp.org/extensions/xep-0377.html#revision-history-v0.3
author | Martin Dosch <martin@mdosch.de> |
---|---|
date | Thu, 01 Jul 2021 21:07:38 +0200 |
parents | a59671b3dd43 |
children | 4eb684ab440c |
line wrap: on
line diff
--- a/mod_spam_reporting/mod_spam_reporting.lua Thu Jul 01 21:00:03 2021 +0200 +++ b/mod_spam_reporting/mod_spam_reporting.lua Thu Jul 01 21:07:38 2021 +0200 @@ -10,6 +10,7 @@ module:add_feature("urn:xmpp:reporting:0"); module:add_feature("urn:xmpp:reporting:reason:spam:0"); module:add_feature("urn:xmpp:reporting:reason:abuse:0"); +module:add_feature("urn:xmpp:reporting:1"); module:hook("iq-set/self/urn:xmpp:blocking:block", function (event) for item in event.stanza.tags[1]:childtags("item") do @@ -24,6 +25,22 @@ module:fire_event(module.name.."/"..type.."-report", { origin = event.origin, stanza = event.stanza, jid = jid, item = item, report = report, reason = reason, }); + else + report = item:get_child("report", "urn:xmpp:reporting:1"); + if report and jid then + local type + if report.attr.reason == "urn:xmpp:reporting:abuse" then + type = "abuse"; + end + if report.attr.reason == "urn:xmpp:reporting:spam" then + type = "spam"; + end + local reason = report:get_child_text("text") or "no reason given"; + module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason); + module:fire_event(module.name.."/"..type.."-report", { + origin = event.origin, stanza = event.stanza, jid = jid, + item = item, report = report, reason = reason, }); + end end end end, 1);