Mercurial > prosody-modules
comparison mod_report_forward/mod_report_forward.lua @ 6114:fc521fb5ffa0
mod_report_forward: Measure number of forwarded reports
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 08 Jan 2025 09:21:25 +0100 |
| parents | 226886ffafb0 |
| children |
comparison
equal
deleted
inserted
replaced
| 6113:83adef4f7d2e | 6114:fc521fb5ffa0 |
|---|---|
| 3 local st = require "util.stanza"; | 3 local st = require "util.stanza"; |
| 4 local url = require "socket.url"; | 4 local url = require "socket.url"; |
| 5 | 5 |
| 6 local new_id = require "util.id".short; | 6 local new_id = require "util.id".short; |
| 7 local render = require"util.interpolation".new("%b{}", function (s) return s; end); | 7 local render = require"util.interpolation".new("%b{}", function (s) return s; end); |
| 8 | |
| 9 local count_report = module:metric("counter", "forwarded", "reports", "Number of spam and abuse reports forwarded to remote receivers."); | |
| 8 | 10 |
| 9 module:depends("spam_reporting"); | 11 module:depends("spam_reporting"); |
| 10 | 12 |
| 11 local destinations = module:get_option_set("report_forward_to", {}); | 13 local destinations = module:get_option_set("report_forward_to", {}); |
| 12 | 14 |
| 139 :add_child(reported_message); | 141 :add_child(reported_message); |
| 140 message:add_child(fwd); | 142 message:add_child(fwd); |
| 141 end | 143 end |
| 142 | 144 |
| 143 for destination in destinations do | 145 for destination in destinations do |
| 146 count_report:with_labels():add(1); | |
| 144 send_report(destination, message); | 147 send_report(destination, message); |
| 145 end | 148 end |
| 146 | 149 |
| 147 if report_to_origin then | 150 if report_to_origin then |
| 148 module:log("debug", "Sending report to origin server..."); | 151 module:log("debug", "Sending report to origin server..."); |
