From: Vsevolod Stakhov Date: Wed, 1 Jul 2020 11:02:21 +0000 (+0100) Subject: [Feature] Add maps query method X-Git-Tag: 2.6~278 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b00eb164fb661201e3a29a72522d911731f12f25;p=thirdparty%2Frspamd.git [Feature] Add maps query method --- diff --git a/rules/controller/maps.lua b/rules/controller/maps.lua index 42d761172f..ec2392d569 100644 --- a/rules/controller/maps.lua +++ b/rules/controller/maps.lua @@ -47,8 +47,23 @@ end local function handle_query_map(_, conn, req_params) maybe_fill_maps_cache() if req_params.value and req_params.value ~= '' then + local results = {} + for uri,m in pairs(maps_cache) do + local value = m:get_key(req_params.value) - conn:send_ucl({success = false and true}) + if value then + local result = { + map = uri, + alias = uri:match('/([^/]+)$'), + value = value + } + table.insert(results, result) + end + end + conn:send_ucl{ + success = (#results > 0), + results = results + } else conn:send_error(404, 'missing value') end