Mercurial > prosody-modules
comparison mod_spam_reporting/mod_spam_reporting.lua @ 4659:cc8b221f137c
mod_spam_reporting: Rename variable avoid name clash with global function
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 25 Aug 2021 18:56:45 +0200 |
| parents | ff68cc37b400 |
| children | ce826ac8496e |
comparison
equal
deleted
inserted
replaced
| 4658:ff68cc37b400 | 4659:cc8b221f137c |
|---|---|
| 15 module:hook("iq-set/self/urn:xmpp:blocking:block", function (event) | 15 module:hook("iq-set/self/urn:xmpp:blocking:block", function (event) |
| 16 for item in event.stanza.tags[1]:childtags("item") do | 16 for item in event.stanza.tags[1]:childtags("item") do |
| 17 local report = item:get_child("report", "urn:xmpp:reporting:0"); | 17 local report = item:get_child("report", "urn:xmpp:reporting:0"); |
| 18 local jid = jid_prep(item.attr.jid); | 18 local jid = jid_prep(item.attr.jid); |
| 19 if report and jid then | 19 if report and jid then |
| 20 local type = report:get_child("spam") and "spam" or | 20 local report_type = report:get_child("spam") and "spam" or |
| 21 report:get_child("abuse") and "abuse" or | 21 report:get_child("abuse") and "abuse" or |
| 22 "unknown"; | 22 "unknown"; |
| 23 local reason = report:get_child_text("text"); | 23 local reason = report:get_child_text("text"); |
| 24 module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason); | 24 module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason); |
| 25 module:fire_event(module.name.."/"..type.."-report", { | 25 module:fire_event(module.name.."/"..report_type.."-report", { |
| 26 origin = event.origin, stanza = event.stanza, jid = jid, | 26 origin = event.origin, stanza = event.stanza, jid = jid, |
| 27 item = item, report = report, reason = reason, }); | 27 item = item, report = report, reason = reason, }); |
| 28 else | 28 else |
| 29 report = item:get_child("report", "urn:xmpp:reporting:1"); | 29 report = item:get_child("report", "urn:xmpp:reporting:1"); |
| 30 if report and jid then | 30 if report and jid then |
| 31 local type = "unknown"; | 31 local report_type = "unknown"; |
| 32 if report.attr.reason == "urn:xmpp:reporting:abuse" then | 32 if report.attr.reason == "urn:xmpp:reporting:abuse" then |
| 33 type = "abuse"; | 33 report_type = "abuse"; |
| 34 end | 34 end |
| 35 if report.attr.reason == "urn:xmpp:reporting:spam" then | 35 if report.attr.reason == "urn:xmpp:reporting:spam" then |
| 36 type = "spam"; | 36 report_type = "spam"; |
| 37 end | 37 end |
| 38 local reason = report:get_child_text("text"); | 38 local reason = report:get_child_text("text"); |
| 39 module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason); | 39 module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason); |
| 40 module:fire_event(module.name.."/"..type.."-report", { | 40 module:fire_event(module.name.."/"..report_type.."-report", { |
| 41 origin = event.origin, stanza = event.stanza, jid = jid, | 41 origin = event.origin, stanza = event.stanza, jid = jid, |
| 42 item = item, report = report, reason = reason, }); | 42 item = item, report = report, reason = reason, }); |
| 43 end | 43 end |
| 44 end | 44 end |
| 45 end | 45 end |
