From: Alexander Moisseev Date: Sat, 21 Jun 2025 14:12:03 +0000 (+0300) Subject: [Minor] Add /plugins/fuzzy/storages endpoint X-Git-Tag: 3.13.0~51^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=564cb4a324abcc07aaaefd6a66a0e34ba49f8e9a;p=thirdparty%2Frspamd.git [Minor] Add /plugins/fuzzy/storages endpoint Allows retrieving the list of configured fuzzy storages via HTTP API, including associated flags, read_only status, and server addresses. --- diff --git a/rules/controller/fuzzy.lua b/rules/controller/fuzzy.lua index 193e6fd4c3..06f5d43d92 100644 --- a/rules/controller/fuzzy.lua +++ b/rules/controller/fuzzy.lua @@ -37,10 +37,30 @@ local function handle_gen_fuzzy(task, conn, req_params) end end +local function handle_fuzzy_storages(_task, conn) + if type(rspamd_plugins.fuzzy_check) == 'table' + and type(rspamd_plugins.fuzzy_check.list_storages) == 'function' then + local ok, result = pcall(rspamd_plugins.fuzzy_check.list_storages, rspamd_config) + + if ok then + conn:send_ucl({ success = true, storages = result }) + else + conn:send_error(500, 'cannot list fuzzy storages') + end + else + conn:send_error(404, 'fuzzy_check is not enabled') + end +end + return { hashes = { handler = handle_gen_fuzzy, need_task = true, enable = false }, -} \ No newline at end of file + storages = { + handler = handle_fuzzy_storages, + need_task = false, + enable = false + }, +}