From 29c3237009537015e66875ab9ce1fbe3e101576b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 22 Dec 2010 18:08:14 +0300 Subject: * Add versions to lua API * Provide compatibility for lua plugins for old versions of rspamd --- src/plugins/lua/multimap.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/plugins/lua/multimap.lua') 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 -- cgit v1.2.3