Software /
code /
prosody-modules
Comparison
mod_spam_reporting/mod_spam_reporting.lua @ 2281:0899eeb0b3f7
mod_spam_reporting: Apply JID prepping
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 20 Aug 2016 17:20:52 +0200 |
parent | 2280:ebe360f59119 |
child | 2283:bd1117002a9b |
comparison
equal
deleted
inserted
replaced
2280:ebe360f59119 | 2281:0899eeb0b3f7 |
---|---|
1 -- XEP-0377: Spam Reporting for Prosody | 1 -- XEP-0377: Spam Reporting for Prosody |
2 -- Copyright (C) -2016 Kim Alvefur | 2 -- Copyright (C) -2016 Kim Alvefur |
3 -- | 3 -- |
4 -- This file is MIT/X11 licensed. | 4 -- This file is MIT/X11 licensed. |
5 | |
6 local jid_prep = require "util.jid".prep; | |
5 | 7 |
6 module:depends("blocklist"); | 8 module:depends("blocklist"); |
7 | 9 |
8 module:add_feature("urn:xmpp:reporting:0"); | 10 module:add_feature("urn:xmpp:reporting:0"); |
9 module:add_feature("urn:xmpp:reporting:reason:spam:0"); | 11 module:add_feature("urn:xmpp:reporting:reason:spam:0"); |
10 module:add_feature("urn:xmpp:reporting:reason:abuse:0"); | 12 module:add_feature("urn:xmpp:reporting:reason:abuse:0"); |
11 | 13 |
12 module:hook("iq-set/self/urn:xmpp:blocking:block", function (event) | 14 module:hook("iq-set/self/urn:xmpp:blocking:block", function (event) |
13 for item in event.stanza.tags[1]:childtags("item") do | 15 for item in event.stanza.tags[1]:childtags("item") do |
14 local report = item:get_child("report", "urn:xmpp:reporting:0"); | 16 local report = item:get_child("report", "urn:xmpp:reporting:0"); |
15 local jid = item.attr.jid; | 17 local jid = jid_prep(item.attr.jid); |
16 if report and jid then | 18 if report and jid then |
17 local type = report:get_child("spam") and "spam" or | 19 local type = report:get_child("spam") and "spam" or |
18 report:get_child("abuse") and "abuse" or | 20 report:get_child("abuse") and "abuse" or |
19 "unknown"; | 21 "unknown"; |
20 local reason = report:get_child_text("reason") or "no reason given"; | 22 local reason = report:get_child_text("reason") or "no reason given"; |