# HG changeset patch # User Matthew Wild # Date 1732623179 0 # Node ID 91590d92b91980e30f794dc8e9216482f8677596 # Parent 7d4386cc73d39b288e3609bb5e86e1ae1a015257 mod_report_forward: Add default fallback to domain JID when sending reports No harm in trying... diff -r 7d4386cc73d3 -r 91590d92b919 mod_report_forward/README.md --- a/mod_report_forward/README.md Mon Nov 25 14:33:01 2024 +0000 +++ b/mod_report_forward/README.md Tue Nov 26 12:12:59 2024 +0000 @@ -35,7 +35,9 @@ The module looks up an abuse report address using XEP-0157 (only XMPP addresses are accepted). If it fails to find any suitable destination, it will -log a warning and not send the report. +fall back to sending the report to the domain itself unless `report_forward_to_origin_fallback` +is disabled (set to `false`). If the fallback is disabled, it will log a +warning and not send the report. diff -r 7d4386cc73d3 -r 91590d92b919 mod_report_forward/mod_report_forward.lua --- a/mod_report_forward/mod_report_forward.lua Mon Nov 25 14:33:01 2024 +0000 +++ b/mod_report_forward/mod_report_forward.lua Tue Nov 26 12:12:59 2024 +0000 @@ -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", [[ @@ -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, "spam-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