From: Andrew Lewis Date: Tue, 12 Dec 2023 07:52:45 +0000 (+0200) Subject: [Minor] Have bayes use global redis settings X-Git-Tag: 3.8.0~37^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4da87a5cdaa931a7e0e716b8095594d3cdae0287;p=rspamd.git [Minor] Have bayes use global redis settings --- 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