aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-02-11 16:07:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-02-11 16:07:09 +0000
commit51c3d5bd086c29f313abb5d7789f1f821c4452ce (patch)
treea527d85a5ab1138eed19f9c80381b1bbb877dcf2 /src/plugins
parentc31bcafb72f6be50c20f7d429103dd6ff7723c56 (diff)
downloadrspamd-51c3d5bd086c29f313abb5d7789f1f821c4452ce.tar.gz
rspamd-51c3d5bd086c29f313abb5d7789f1f821c4452ce.zip
[Minor] Milter_headers: Allow to sort symbols
Issue: #3642
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/milter_headers.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index 3b0037a09..305cc6411 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -53,7 +53,7 @@ local settings = {
header = 'X-Spamd-Result',
remove = 0,
stop_chars = ' ',
- sort_by = 'name',
+ sort_by = 'score',
},
['x-rspamd-server'] = {
header = 'X-Rspamd-Server',
@@ -249,6 +249,18 @@ local function milter_headers(task)
table.insert(buf, verdict)
-- Deal with symbols
+ table.sort(common.symbols, function(s1, s2)
+ local res
+ if local_mod.sort_by == 'name' then
+ res = s1.name < s2.name
+ else
+ -- inverse order to show important symbols first
+ res = math.abs(s1.score) > math.abs(s2.score)
+ end
+
+ return res
+ end)
+
for _, s in ipairs(common.symbols) do
local sym_str = string.format('%s(%.2f)[%s]',
s.name, s.score, table.concat(s.options or {}, ','))