return false, string.format( 'cannot convert %q to boolean', v);
end
elseif type(v) == 'number' then
- return (not (v == 0))
+ return v ~= 0
else
return false, string.format( 'cannot convert %q to boolean', v);
end
local function register_lock_extender(rule, set, ev_base, ann_key)
rspamd_config:add_periodic(ev_base, 30.0,
function()
- local function redis_lock_extend_cb(_err, _)
- if _err then
+ local function redis_lock_extend_cb(err, _)
+ if err then
rspamd_logger.errx(rspamd_config, 'cannot lock ANN %s from redis: %s',
- ann_key, _err)
+ ann_key, err)
else
rspamd_logger.infox(rspamd_config, 'extend lock for ANN %s for 30 seconds',
ann_key)
end
-- Sort by checked
-local function sort_ips(tbl, _opts)
+local function sort_ips(tbl, sort_opts)
local res = {}
for k,v in pairs(tbl) do
table.insert(res, {ip = k, data = v})
local key = 'checked'
local _res = 0
- if _opts['sort'] then
- if _opts['sort'] == 'matched' then
+ if sort_opts['sort'] then
+ if sort_opts['sort'] == 'matched' then
key = 'matched'
- elseif _opts['sort'] == 'errors' then
+ elseif sort_opts['sort'] == 'errors' then
key = 'errors'
- elseif _opts['sort'] == 'ip' then
+ elseif sort_opts['sort'] == 'ip' then
return elt['ip']
end
end
end
-- Do not write the last chunk of out as it will be processed afterwards
- if not cursor == 0 then
+ if cursor ~= 0 then
if opts.cdb then
dump_out(out, opts, false)
clear_fcn(out)