comparison mod_firewall/actions.lib.lua @ 5235:d0d251abf595

mod_firewall: Add 'REPORT TO' to report (XEP-0377) a stanza to a specified JID
author Matthew Wild <mwild1@gmail.com>
date Sat, 11 Mar 2023 18:41:49 +0000
parents 5a3dfb970888
children 96dec7681af8
comparison
equal deleted inserted replaced
5234:f6c71d9d6dc0 5235:d0d251abf595
239 rostermanager.roster_push(to_node, to_host, bare_from);\ 239 rostermanager.roster_push(to_node, to_host, bare_from);\
240 core_post_stanza(session, st.presence({ from = bare_to, to = bare_from, type = \"unsubscribed\" }));", 240 core_post_stanza(session, st.presence({ from = bare_to, to = bare_from, type = \"unsubscribed\" }));",
241 { "rostermanager", "core_post_stanza", "st", "split_to", "bare_to", "bare_from" }; 241 { "rostermanager", "core_post_stanza", "st", "split_to", "bare_to", "bare_from" };
242 end 242 end
243 243
244 function action_handlers.REPORT_TO(spec)
245 local where, reason, text = spec:match("^%s*(%S+) *(%S*) *(.*)$");
246 if reason == "spam" then
247 reason = "urn:xmpp:reporting:spam";
248 elseif reason == "abuse" or not reason then
249 reason = "urn:xmpp:reporting:abuse";
250 end
251 local code = [[
252 local newstanza = st.stanza("message", { to = %q, from = current_host }):tag("forwarded", { xmlns = "urn:xmpp:forward:0" });
253 local tmp_stanza = st.clone(stanza); tmp_stanza.attr.xmlns = "jabber:client"; newstanza:add_child(tmp_stanza):up();
254 newstanza:tag("report", { xmlns = "urn:xmpp:reporting:1", reason = %q })
255 do local text = %q; if text ~= "" then newstanza:text_tag("text", text); end end
256 newstanza:up();
257 core_post_stanza(session, newstanza);
258 ]];
259 return code:format(where, reason, text), { "core_post_stanza", "current_host", "st" };
260 end
261
244 return action_handlers; 262 return action_handlers;