From 2c3dbe5779e488ea7d467c9f0c28831b444a1d4c Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Fri, 28 Feb 2025 10:09:52 +0200 Subject: [PATCH] [Minor] Fix luacheck complaints --- src/plugins/lua/contextal.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/plugins/lua/contextal.lua b/src/plugins/lua/contextal.lua index 341b7a125b..8cc5cf1d05 100644 --- a/src/plugins/lua/contextal.lua +++ b/src/plugins/lua/contextal.lua @@ -33,6 +33,8 @@ local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" local ucl = require "ucl" +local redis_params + local contextal_actions = { 'ALERT', 'ALLOW', @@ -83,12 +85,18 @@ local function process_actions(task, obj, is_cached) return end + local function redis_set_cb(err) + if err then + rspamd_logger.err(task, 'error setting cache: %s', err) + end + end + local key = cache_key(task) local ret = lua_redis.redis_make_request(task, redis_params, -- connect params key, -- hash key true, -- is write - redis_get_cb, --callback + redis_set_cb, --callback 'SET', -- command { key, ucl.to_format(cache_obj, 'json-compact') } -- arguments ) @@ -129,8 +137,8 @@ local function submit(task) return end local parser = ucl.parser() - local _, err = parser:parse_string(body) - if err then + local _, parse_err = parser:parse_string(body) + if parse_err then rspamd_logger.err(task, 'cannot parse JSON: %s', err) return end @@ -218,8 +226,8 @@ local function action_cb(task) return end local parser = ucl.parser() - local _, err = parser:parse_string(body) - if err then + local _, parse_err = parser:parse_string(body) + if parse_err then rspamd_logger.err(task, 'cannot parse JSON: %s', err) return end @@ -245,9 +253,6 @@ local function set_url_path(base, path) return base .. ts .. path end -local opts = rspamd_config:get_all_opt(N) -if not opts then return end - settings = lua_util.override_defaults(settings, opts) contextal_actions = lua_util.list_to_hash(contextal_actions) -- 2.47.3