mod_watch_spam_reports/mod_watch_spam_reports.lua
author Martin Dosch <martin@mdosch.de>
Wed, 24 Jun 2020 08:51:07 +0200
changeset 4055 91e2e510e17c
parent 4050 d518f97dad6f
child 4056 0d6841e0cb18
permissions -rw-r--r--
mod_watch_spam_reports: Show reporters bare JID instead of full JID
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4055
91e2e510e17c mod_watch_spam_reports: Show reporters bare JID instead of full JID
Martin Dosch <martin@mdosch.de>
parents: 4050
diff changeset
     1
local jid = require "util.jid";
4050
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     2
local st = require "util.stanza";
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     3
local admins = module:get_option_inherited_set("admins");
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     4
local host = module.host;
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     5
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     6
module:depends("spam_reporting")
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     7
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
     8
module:hook("spam_reporting/spam-report", function(event)
4055
91e2e510e17c mod_watch_spam_reports: Show reporters bare JID instead of full JID
Martin Dosch <martin@mdosch.de>
parents: 4050
diff changeset
     9
	local reporter_bare_jid = jid.bare(event.stanza.attr.from)
4050
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    10
	for admin_jid in admins
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    11
		do
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    12
			module:send(st.message({from=host,
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    13
			type="chat",to=admin_jid},
4055
91e2e510e17c mod_watch_spam_reports: Show reporters bare JID instead of full JID
Martin Dosch <martin@mdosch.de>
parents: 4050
diff changeset
    14
			reporter_bare_jid.." reported "..event.jid.." as spammer: "..event.reason));
4050
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    15
		end
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    16
end)