From: Anton Yuzhaninov Date: Tue, 18 Aug 2020 17:45:30 +0000 (+0100) Subject: [Minor] Save into ClickHouse unnamed attaches X-Git-Tag: 2.6~146^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F3474%2Fhead;p=rspamd.git [Minor] Save into ClickHouse unnamed attaches Most MUA allow to save attachments (parts with Content-Disposition: attachment) even if don't have a name. Keep name field empty and save other information about such attachments to ClickHouse: Content-Type, size, digest. Modify attachments selector as well to return hashes of unnamed attachments. --- diff --git a/lualib/lua_selectors/extractors.lua b/lualib/lua_selectors/extractors.lua index d88eaa216..4727b389c 100644 --- a/lualib/lua_selectors/extractors.lua +++ b/lualib/lua_selectors/extractors.lua @@ -135,7 +135,7 @@ uses any type by default)]], local parts = task:get_parts() or E local digests = {} for i,p in ipairs(parts) do - if p:get_filename() then + if p:is_attachment() then table.insert(digests, common.get_cached_or_raw_digest(task, i, p, args)) end end diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 734832d57..487997ddd 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -726,11 +726,9 @@ local function clickhouse_collect(task) local attachments_ctypes = {} local attachments_lengths = {} local attachments_digests = {} - for _,part in ipairs(task:get_parts()) do - local fname = part:get_filename() - - if fname then - table.insert(attachments_fnames, fname) + for _, part in ipairs(task:get_parts()) do + if part:is_attachment() then + table.insert(attachments_fnames, part:get_filename() or '') local mime_type, mime_subtype = part:get_type() table.insert(attachments_ctypes, string.format("%s/%s", mime_type, mime_subtype)) table.insert(attachments_lengths, part:get_length())