diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-12-22 18:08:14 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-12-22 18:08:14 +0300 |
commit | 29c3237009537015e66875ab9ce1fbe3e101576b (patch) | |
tree | ae47f0223ed9f5c133f60580d9ffc4d811b47fdf /src/plugins/lua/multimap.lua | |
parent | 501f1465ff2e985def4159ab32de267e7b111624 (diff) | |
download | rspamd-29c3237009537015e66875ab9ce1fbe3e101576b.tar.gz rspamd-29c3237009537015e66875ab9ce1fbe3e101576b.zip |
* Add versions to lua API
* Provide compatibility for lua plugins for old versions of rspamd
Diffstat (limited to 'src/plugins/lua/multimap.lua')
-rw-r--r-- | src/plugins/lua/multimap.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 97f122c48..6986c8c72 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -130,7 +130,11 @@ function add_rule(params) end -- Registration -rspamd_config:register_module_option('multimap', 'rule', 'string') +if type(rspamd_config.get_api_version) ~= 'nil' then + if rspamd_config:get_api_version() >= 1 then + rspamd_config:register_module_option('multimap', 'rule', 'string') + end +end local opts = rspamd_config:get_all_opt('multimap') if opts then @@ -143,7 +147,9 @@ if opts then if not rule then rspamd_logger:err('cannot add rule: "'..value..'"') else - rspamd_config:register_virtual_symbol(rule['symbol'], 1.0) + if type(rspamd_config.get_api_version) ~= 'nil' then + rspamd_config:register_virtual_symbol(rule['symbol'], 1.0) + end end end elseif type(strrules) == 'string' then @@ -152,7 +158,9 @@ if opts then if not rule then rspamd_logger:err('cannot add rule: "'..strrules..'"') else - rspamd_config:register_virtual_symbol(rule['symbol'], 1.0) + if type(rspamd_config.get_api_version) ~= 'nil' then + rspamd_config:register_virtual_symbol(rule['symbol'], 1.0) + end end end end @@ -160,5 +168,9 @@ end if table.maxn(rules) > 0 then -- add fake symbol to check all maps inside a single callback - rspamd_config:register_callback_symbol('MULTIMAP', 1.0, 'check_multimap') + if type(rspamd_config.get_api_version) ~= 'nil' then + rspamd_config:register_callback_symbol('MULTIMAP', 1.0, 'check_multimap') + else + rspamd_config:register_symbol('MULTIMAP', 1.0, 'check_multimap') + end end |