diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-06-10 15:45:29 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-06-10 15:45:29 +0200 |
commit | c30cfcb21a5d1b2fa14944ff3633198a95ea3c2d (patch) | |
tree | a947837bbd92ed3bdf4a22b54dd6b492e9500246 /src/plugins/lua/metadata_exporter.lua | |
parent | cd0cc6187ed4b153e3506bbf79d28aa760a85f4a (diff) | |
download | rspamd-c30cfcb21a5d1b2fa14944ff3633198a95ea3c2d.tar.gz rspamd-c30cfcb21a5d1b2fa14944ff3633198a95ea3c2d.zip |
[Feature] Bayes expiry plugin
Diffstat (limited to 'src/plugins/lua/metadata_exporter.lua')
-rw-r--r-- | src/plugins/lua/metadata_exporter.lua | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index f0b3f175d..2268c86f5 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -22,6 +22,7 @@ end -- A plugin that pushes metadata (or whole messages) to external services local redis_params +local lutil = require "lua_util" local rspamd_http = require "rspamd_http" local rspamd_tcp = require "rspamd_tcp" local rspamd_util = require "rspamd_util" @@ -136,18 +137,6 @@ local function get_general_metadata(task, flatten, no_content) return r end -local function simple_template(tmpl, keys) - local lpeg = require "lpeg" - - local var_lit = lpeg.P { lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + "_" } - local var = lpeg.P { (lpeg.P("$") / "") * ((var_lit^1) / keys) } - local var_braced = lpeg.P { (lpeg.P("${") / "") * ((var_lit^1) / keys) * (lpeg.P("}") / "") } - - local template_grammar = lpeg.Cs((var + var_braced + 1)^0) - - return lpeg.match(template_grammar, tmpl) -end - local formatters = { default = function(task) return task:get_content() @@ -158,7 +147,7 @@ local formatters = { meta.mail_to = rule.mail_to or settings.mail_to meta.our_message_id = rspamd_util.random_hex(12) .. '@rspamd' meta.date = rspamd_util.time_to_string(rspamd_util.get_time()) - return simple_template(rule.email_template or settings.email_template, meta) + return lutil.template(rule.email_template or settings.email_template, meta) end, json = function(task) return ucl.to_format(get_general_metadata(task), 'json-compact') |