Mercurial > prosody-modules
diff mod_report_forward/mod_report_forward.lua @ 6110:9db1529c06c2
Merge upstream
| author | tmolitor <thilo@eightysoft.de> |
|---|---|
| date | Sun, 05 Jan 2025 17:50:02 +0100 |
| parents | 226886ffafb0 |
| children | fc521fb5ffa0 |
line wrap: on
line diff
--- a/mod_report_forward/mod_report_forward.lua Wed Nov 20 05:07:11 2024 +0100 +++ b/mod_report_forward/mod_report_forward.lua Sun Jan 05 17:50:02 2025 +0100 @@ -14,6 +14,7 @@ local cache_size = module:get_option_number("report_forward_contact_cache_size", 256); local report_to_origin = module:get_option_boolean("report_forward_to_origin", true); +local report_to_origin_fallback = module:get_option_boolean("report_forward_to_origin_fallback", true); local contact_lookup_timeout = module:get_option_number("report_forward_contact_lookup_timeout", 180); local body_template = module:get_option_string("report_forward_body_template", [[ @@ -30,7 +31,7 @@ -- This message contains also machine-readable payloads, including XEP-0377, in case you want to automate handling of these reports. You can receive these reports -to a different address by setting 'spam-report-addresses' in your server +to a different address by setting 'report-addresses' in your server contact info configuration. For more information, see https://xmppbl.org/reports/ ]]):gsub("^%s+", ""):gsub("(%S)\n(%S)", "%1 %2"); @@ -65,18 +66,27 @@ :next(function (result) module:log("debug", "Processing contact form..."); local response = result.stanza; - if response.attr.type ~= "result" then - module:log("warn", "Failed to query contact addresses of %s: %s", host, response); - return; + if response.attr.type == "result" then + for form in response.tags[1]:childtags("x", "jabber:x:data") do + local form_type = form:get_child_with_attr("field", nil, "var", "FORM_TYPE"); + if form_type and form_type:get_child_text("value") == "http://jabber.org/network/serverinfo" then + address = get_address(form, "report-addresses", "abuse-addresses"); + break; + end + end end - for form in response.tags[1]:childtags("x", "jabber:x:data") do - local form_type = form:get_child_with_attr("field", nil, "var", "FORM_TYPE"); - if form_type and form_type:get_child_text("value") == "http://jabber.org/network/serverinfo" then - address = get_address(form, "spam-report-addresses", "abuse-addresses"); - break; + if not address then + if report_to_origin_fallback then + -- If no contact address found, but fallback is enabled, + -- just send the report to the domain + module:log("debug", "Falling back to domain to send report to %s", host); + address = host; + else + module:log("warn", "Failed to query contact addresses of %s: %s", host, response); end end + return address; end); end
