view mod_watch_spam_reports/mod_watch_spam_reports.lua @ 4657:78ef5d9e2361

mod_watch_spam_reports: Prepare for changing 'reason' to an optional value
author Kim Alvefur <zash@zash.se>
date Wed, 25 Aug 2021 16:31:10 +0200
parents 7a9e1c81c63e
children 6e5572fc6840
line wrap: on
line source

local jid = require "util.jid";
local st = require "util.stanza";
local admins = module:get_option_inherited_set("admins");
local host = module.host;

module:depends("spam_reporting")

module:hook("spam_reporting/spam-report", function(event)
	local reporter_bare_jid = jid.bare(event.stanza.attr.from)
	local report = reporter_bare_jid.." reported spam from "..event.jid..": "..(event.reason or "no reason given")
	for admin_jid in admins
		do
			module:send(st.message({from=host,
			type="chat",to=admin_jid},
			report));
		end
end)

module:hook("spam_reporting/abuse-report", function(event)
	local reporter_bare_jid = jid.bare(event.stanza.attr.from)
	local report = reporter_bare_jid.." reported abuse from "..event.jid..": "..(event.reason or "no reason given")
	for admin_jid in admins
		do
			module:send(st.message({from=host,
			type="chat",to=admin_jid},
			report));
		end
end)