aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/milter_headers.lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2017-06-21 12:12:20 +0200
committerAndrew Lewis <nerf@judo.za.org>2017-06-21 12:12:20 +0200
commit1021fd7dcba904bbd4f5424d4a9ccccfabbcadf1 (patch)
tree3d17bdd4e36a16428b8ba0ad86b03b834a32cc23 /src/plugins/lua/milter_headers.lua
parentfa4f75e41ebcbf9a45c0077ca040db3df9dc0936 (diff)
downloadrspamd-1021fd7dcba904bbd4f5424d4a9ccccfabbcadf1.tar.gz
rspamd-1021fd7dcba904bbd4f5424d4a9ccccfabbcadf1.zip
[Feature] Milter headers: Add X-Spam-Flag to rmilter-compatibility headers
Diffstat (limited to 'src/plugins/lua/milter_headers.lua')
-rw-r--r--src/plugins/lua/milter_headers.lua36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index c0e75289e..a2bc8a97d 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -39,6 +39,11 @@ local settings = {
header = 'X-Spamd-Result',
remove = 1,
},
+ ['x-spam-flag'] = {
+ header = 'X-Spam-Flag',
+ remove = 1,
+ value = 'Yes',
+ },
['x-rspamd-server'] = {
header = 'X-Rspamd-Server',
remove = 1,
@@ -237,19 +242,41 @@ local function milter_headers(task)
end
routines['spam-header'] = function()
- if skip_wanted('spam-header') then return end
+ if skip_wanted('x-spam-flag') then return end
+ if not common['metric_action'] then
+ common['metric_action'] = task:get_metric_action('default')
+ end
+ if settings.routines['x-spam-flag'].remove then
+ remove[settings.routines['x-spam-flag'].header] = settings.routines['x-spam-flag'].remove
+ end
+ local action = common['metric_action']
+ if action ~= 'no action' and action ~= 'greylist' then
+ add[settings.routines['spam-header'].header] = settings.routines['x-spam-flag'].value
+ end
+ end
+
+ local function spam_header (class, name, value, remove_v)
+ if skip_wanted(class) then return end
if not common['metric_action'] then
common['metric_action'] = task:get_metric_action('default')
end
- if settings.routines['spam-header'].remove then
- remove[settings.routines['spam-header'].header] = settings.routines['spam-header'].remove
+ if remove_v then
+ remove[name] = remove_v
end
local action = common['metric_action']
if action ~= 'no action' and action ~= 'greylist' then
- add[settings.routines['spam-header'].header] = settings.routines['spam-header'].value
+ add[name] = value
end
end
+ routines['spam-header'] = function()
+ spam_header('spam-header', settings.routines['spam-header'].header, settings.routines['spam-header'].value, settings.routines['spam-header'].remove)
+ end
+
+ routines['x-spam-flag'] = function()
+ spam_header('x-spam-flag', settings.routines['x-spam-flag'].header, settings.routines['x-spam-flag'].value, settings.routines['x-spam-flag'].remove)
+ end
+
routines['x-virus'] = function()
if skip_wanted('x-virus') then return end
if not common.symbols then
@@ -386,6 +413,7 @@ if opts['extended_spam_headers'] then
activate_routine('x-spamd-result')
activate_routine('x-rspamd-server')
activate_routine('x-rspamd-queue-id')
+ activate_routine('x-spam-flag')
end
if type(opts['use']) == 'string' then
opts['use'] = {opts['use']}