aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_bayes_redis.lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2023-12-12 09:52:45 +0200
committerAndrew Lewis <nerf@judo.za.org>2023-12-12 09:52:45 +0200
commit4da87a5cdaa931a7e0e716b8095594d3cdae0287 (patch)
treedbaf94e951038b4a3d5032686ae3607575dcb285 /lualib/lua_bayes_redis.lua
parenta639c5fae0943ce758e9dc36cb57a2e81849c933 (diff)
downloadrspamd-4da87a5cdaa931a7e0e716b8095594d3cdae0287.tar.gz
rspamd-4da87a5cdaa931a7e0e716b8095594d3cdae0287.zip
[Minor] Have bayes use global redis settings
Diffstat (limited to 'lualib/lua_bayes_redis.lua')
-rw-r--r--lualib/lua_bayes_redis.lua25
1 files changed, 19 insertions, 6 deletions
diff --git a/lualib/lua_bayes_redis.lua b/lualib/lua_bayes_redis.lua
index d84d67498..96a505518 100644
--- a/lualib/lua_bayes_redis.lua
+++ b/lualib/lua_bayes_redis.lua
@@ -66,20 +66,33 @@ end
exports.lua_bayes_init_statfile = function(classifier_ucl, statfile_ucl, symbol, is_spam, ev_base, stat_periodic_cb)
local redis_params
- if classifier_ucl.backend then
- redis_params = lua_redis.try_load_redis_servers(classifier_ucl.backend, rspamd_config, true)
+ -- Try load from statfile options
+ if statfile_ucl.redis then
+ redis_params = lua_redis.try_load_redis_servers(statfile_ucl.redis, rspamd_config, true)
end
- -- Try load from statfile options
if not redis_params then
if statfile_ucl then
redis_params = lua_redis.try_load_redis_servers(statfile_ucl, rspamd_config, true)
end
end
- -- Load directly from classifier config
+ -- Try load from classifier config
+ if not redis_params and classifier_ucl.backend then
+ redis_params = lua_redis.try_load_redis_servers(classifier_ucl.backend, rspamd_config, true)
+ end
+
+ if not redis_params and classifier_ucl.redis then
+ redis_params = lua_redis.try_load_redis_servers(classifier_ucl.redis, rspamd_config, true)
+ end
+
+ if not redis_params then
+ redis_params = lua_redis.try_load_redis_servers(classifier_ucl, rspamd_config, true)
+ end
+
+ -- Try load global options
if not redis_params then
- redis_params = lua_redis.try_load_redis_servers(classifier_ucl, rspamd_config, false, "statistics")
+ redis_params = lua_redis.try_load_redis_servers(rspamd_config:get_all_opt('redis'), rspamd_config, true)
end
if not redis_params then
@@ -140,4 +153,4 @@ exports.lua_bayes_init_statfile = function(classifier_ucl, statfile_ucl, symbol,
return gen_classify_functor(redis_params, classify_script_id), gen_learn_functor(redis_params, learn_script_id)
end
-return exports \ No newline at end of file
+return exports