From 54ddf6b74babe0bdcf2e455ba287b4afeb94c872 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Thu, 10 Nov 2016 09:27:08 +0200 Subject: [PATCH] [Minor] Metadata exporter: make use of select function optional - Sometimes one might want to fold this functionality into format() --- src/plugins/lua/metadata_exporter.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index 462748ba2..eb463a2ca 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -20,9 +20,6 @@ limitations under the License. local rspamd_logger = require "rspamd_logger" local settings = { - select = function(task) - return true - end, format = function(task) return task:get_content() end, @@ -58,15 +55,22 @@ local function metadata_exporter(task) upstream:ok() end end - if not settings.select(task) then return end - rspamd_logger.debugx(task, 'Message selected for processing') + if settings.select then + if not settings.select(task) then return end + rspamd_logger.debugx(task, 'Message selected for processing') + end + local data = settings.format(task) + if not data then + rspamd_logger.debugx(task, 'Format returned non-truthy value: %1', data) + return + end ret,conn,upstream = rspamd_redis_make_request(task, redis_params, -- connect params nil, -- hash key true, -- is write redis_set_cb, --callback 'PUBLISH', -- command - {channel, settings.format(task)} -- arguments + {channel, data} -- arguments ) end -- 2.39.5