Annotate

mod_report_forward/mod_report_forward.lua @ 5879:05356f2d4425

mod_report_forward: Open archive store correctly (thanks Menel)
author Matthew Wild <mwild1@gmail.com>
date Sun, 03 Mar 2024 16:05:04 +0000
parent 5878:fcfe490de8a4
child 5880:6fe4dab27187
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
1 local dt = require "util.datetime";
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
2 local jid = require "util.jid";
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local st = require "util.stanza";
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
4 local url = require "socket.url";
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
5
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
6 local new_id = require "util.id".short;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
7 local render = require"util.interpolation".new("%b{}", function (s) return s; end);
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8
5878
fcfe490de8a4 mod_spam_report_forwarder: Rename to mod_report_forward
Matthew Wild <mwild1@gmail.com>
parents: 5871
diff changeset
9 local destinations = module:get_option_set("report_forward_to", {});
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
5879
05356f2d4425 mod_report_forward: Open archive store correctly (thanks Menel)
Matthew Wild <mwild1@gmail.com>
parents: 5878
diff changeset
11 local archive = module:open_store("archive", "archive");
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
12
5878
fcfe490de8a4 mod_spam_report_forwarder: Rename to mod_report_forward
Matthew Wild <mwild1@gmail.com>
parents: 5871
diff changeset
13 local cache_size = module:get_option_number("report_forward_contact_cache_size", 256);
fcfe490de8a4 mod_spam_report_forwarder: Rename to mod_report_forward
Matthew Wild <mwild1@gmail.com>
parents: 5871
diff changeset
14 local report_to_origin = module:get_option_boolean("report_forward_to_origin", true);
fcfe490de8a4 mod_spam_report_forwarder: Rename to mod_report_forward
Matthew Wild <mwild1@gmail.com>
parents: 5871
diff changeset
15 local contact_lookup_timeout = module:get_option_number("report_forward_contact_lookup_timeout", 180);
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
16
5878
fcfe490de8a4 mod_spam_report_forwarder: Rename to mod_report_forward
Matthew Wild <mwild1@gmail.com>
parents: 5871
diff changeset
17 local body_template = module:get_option_string("report_forward_body_template", [[
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
18 SPAM/ABUSE REPORT
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
19 -----------------
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
20
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
21 Reported JID: {reported_jid}
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
22
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
23 A user on our service has reported a message originating from the above JID on
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
24 your server.
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
25
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
26 {reported_message_time&The reported message was sent at: {reported_message_time}}
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
27
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
28 --
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
29 This message contains also machine-readable payloads, including XEP-0377, in case
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
30 you want to automate handling of these reports. You can receive these reports
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
31 to a different address by setting 'spam-report-addresses' in your server
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
32 contact info configuration. For more information, see https://xmppbl.org/reports/
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
33 ]]):gsub("^%s+", ""):gsub("(%S)\n(%S)", "%1 %2");
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
34
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
35 local report_addresses = require "util.cache".new(cache_size);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
36
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
37 local function get_address(form, ...)
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
38 for i = 1, select("#", ...) do
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
39 local field_var = select(i, ...);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
40 local field = form:get_child_with_attr("field", "jabber:x:data", "var", field_var);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
41 if field then
5871
d00af6ebb326 mod_spam_report_forwarder: Only forward to xmpp: URIs, and exclude MUCs
Matthew Wild <mwild1@gmail.com>
parents: 5868
diff changeset
42 local parsed = url.parse(field:get_child_text("value"));
d00af6ebb326 mod_spam_report_forwarder: Only forward to xmpp: URIs, and exclude MUCs
Matthew Wild <mwild1@gmail.com>
parents: 5868
diff changeset
43 if parsed.scheme == "xmpp" and parsed.path and not parsed.query then
d00af6ebb326 mod_spam_report_forwarder: Only forward to xmpp: URIs, and exclude MUCs
Matthew Wild <mwild1@gmail.com>
parents: 5868
diff changeset
44 return parsed.path;
d00af6ebb326 mod_spam_report_forwarder: Only forward to xmpp: URIs, and exclude MUCs
Matthew Wild <mwild1@gmail.com>
parents: 5868
diff changeset
45 end
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
46 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
47 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
48 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
49
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
50 local function get_origin_report_address(reported_jid)
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
51 local host = jid.host(reported_jid);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
52 local address = report_addresses:get(host);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
53 if address then return address; end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
54
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
55 local contact_query = st.iq({ to = host, from = module.host, id = new_id() })
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
56 :query("http://jabber.org/protocol/disco#info");
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
57
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
58 return module:send_iq(contact_query, prosody.hosts[module.host], contact_lookup_timeout)
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
59 :next(function (response)
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
60 if response.attr.type ~= "result" then return; end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
61
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
62 for form in response.tags[1]:childtags("x", "jabber:x:data") do
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
63 local form_type = form:get_child_with_attr("field", nil, "var", "FORM_TYPE");
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
64 if form_type == "http://jabber.org/network/serverinfo" then
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
65 address = get_address(form, "spam-report-addresses", "abuse-addresses");
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
66 break;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
67 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
68 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
69 return address;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
70 end);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
71 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
72
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
73 local function send_report(to, message)
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
74 local m = st.clone(message);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
75 m.attr.to = to;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
76 module:send(m);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
77 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
78
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 function forward_report(event)
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
80 local reporter_username = event.origin.username;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
81 local reporter_jid = jid.join(reporter_username, module.host);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
82 local reported_jid = event.jid;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
83
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 local report = st.clone(event.report);
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
85 report:text_tag("jid", reported_jid, { xmlns = "urn:xmpp:jid:0" });
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
86
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
87 local reported_message_id = report:get_child_with_attr(
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
88 "stanza-id",
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
89 "urn:xmpp:sid:0",
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
90 "by",
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
91 reported_jid,
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
92 jid.prep
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
93 );
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
94
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
95 local reported_message, reported_message_time, reported_message_with;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
96 if reported_message_id then
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
97 reported_message, reported_message_time, reported_message_with = archive:get(reporter_username, reported_message_id);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
98 if jid.bare(reported_message_with) ~= event.jid then
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
99 reported_message = nil;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
100 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
101 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
102
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
103 local body_text = render(body_template, {
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
104 reporter_jid = reporter_jid;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
105 reported_jid = event.jid;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
106 reported_message_time = dt.datetime(reported_message_time);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
107 });
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 local message = st.message({ from = module.host })
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
110 :text_tag("body", body_text)
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 :add_child(report);
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
113 if reported_message then
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
114 reported_message.attr.xmlns = "jabber:client";
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
115 local fwd = st.stanza("forwarded", { xmlns = "urn:xmpp:forward:0" })
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
116 :tag("delay", { xmlns = "urn:xmpp:delay", stamp = dt.datetime(reported_message_time) }):up()
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
117 :add_child(reported_message);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
118 message:add_child(fwd);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
119 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
120
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 for destination in destinations do
5868
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
122 send_report(destination, message);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
123 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
124
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
125 if report_to_origin then
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
126 module:log("debug", "Sending report to origin server...");
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
127 get_origin_report_address(event.jid):next(function (origin_report_address)
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
128 if not origin_report_address then
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
129 module:log("warn", "Couldn't report to origin: no contact address found for %s", jid.host(event.jid));
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
130 return;
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
131 end
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
132 send_report(origin_report_address, message);
37e38ee534ea mod_spam_report_forwarder: Support for reporting messages, and reporting to origin server
Matthew Wild <mwild1@gmail.com>
parents: 5238
diff changeset
133 end);
5238
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 end
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 end
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 module:hook("spam_reporting/abuse-report", forward_report, -1);
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 module:hook("spam_reporting/spam-report", forward_report, -1);
94472eb41d0a mod_spam_report_forwarder: Forward spam/abuse reports to one or more JIDs
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 module:hook("spam_reporting/unknown-report", forward_report, -1);