diff options
author | Andrew Lewis <nerf@judo.za.org> | 2020-12-09 16:46:31 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2020-12-09 16:46:31 +0200 |
commit | 838d9dda1a443493d6348b7ce1245717d654e839 (patch) | |
tree | d71e76f11fce4fec312b99ac822569fb36bae2e0 /lualib | |
parent | fe6e15ef22fbdd698d918413bcba382471a8aba3 (diff) | |
download | rspamd-838d9dda1a443493d6348b7ce1245717d654e839.tar.gz rspamd-838d9dda1a443493d6348b7ce1245717d654e839.zip |
[Minor] Selectors: support extracting task cache variables
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_selectors/extractors.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lualib/lua_selectors/extractors.lua b/lualib/lua_selectors/extractors.lua index 3f6dc61ee..0c82d1499 100644 --- a/lualib/lua_selectors/extractors.lua +++ b/lualib/lua_selectors/extractors.lua @@ -363,6 +363,25 @@ e.g. `get_user`]], the second argument is optional and defines the type (string by default)]], ['args_schema'] = {ts.string, ts.string:is_optional()} }, + -- Get value of specific key from task cache + ['task_cache'] = { + ['get_value'] = function(task, args) + local val = task:cache_get(args[1]) + if not val then + return + end + if type(val) == 'table' then + if not val[1] then + return + end + return val, 'string_list' + end + return val, 'string' + end, + ['description'] = [[Get value of specific key from task cache. The first argument must be +the key name]], + ['args_schema'] = {ts.string} + }, -- Get specific HTTP request header. The first argument must be header name. ['request_header'] = { ['get_value'] = function(task, args) |