mod_watch_spam_reports/mod_watch_spam_reports.lua
author Goffi <goffi@goffi.org>
Sat, 10 Jul 2021 16:48:28 +0200
changeset 4620 377546ab50f9
parent 4615 7a9e1c81c63e
child 4661 78ef5d9e2361
permissions -rw-r--r--
mod_delegation: fix bare jid disco nesting bare jid info discovery hook has been accidentally removed a while ago, as a result disco nesting for bare jids was not working anymore.
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)
4065
9745a623c7ed mod_watch_spam_reports: Define variable prior to using it
Martin Dosch <martin@mdosch.de>
parents: 4058
diff changeset
     9
	local reporter_bare_jid = jid.bare(event.stanza.attr.from)
4615
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    10
	local report = reporter_bare_jid.." reported spam from "..event.jid..": "..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
    11
	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
    12
		do
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    13
			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
    14
			type="chat",to=admin_jid},
4065
9745a623c7ed mod_watch_spam_reports: Define variable prior to using it
Martin Dosch <martin@mdosch.de>
parents: 4058
diff changeset
    15
			report));
4050
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
d518f97dad6f mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff changeset
    17
end)
4615
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    18
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    19
module:hook("spam_reporting/abuse-report", function(event)
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    20
	local reporter_bare_jid = jid.bare(event.stanza.attr.from)
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    21
	local report = reporter_bare_jid.." reported abuse from "..event.jid..": "..event.reason
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    22
	for admin_jid in admins
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    23
		do
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    24
			module:send(st.message({from=host,
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    25
			type="chat",to=admin_jid},
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    26
			report));
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    27
		end
7a9e1c81c63e mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents: 4065
diff changeset
    28
end)