]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add /plugins/fuzzy/storages endpoint
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sat, 21 Jun 2025 14:12:03 +0000 (17:12 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Wed, 25 Jun 2025 13:59:27 +0000 (16:59 +0300)
Allows retrieving the list of configured fuzzy storages via HTTP API,
including associated flags, read_only status, and server addresses.

rules/controller/fuzzy.lua

index 193e6fd4c36375dea43c2fde8884bf09e0ba1115..06f5d43d9288d12528f267c878318f66c92eafdf 100644 (file)
@@ -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
+  },
+}