]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Save into ClickHouse unnamed attaches 3474/head
authorAnton Yuzhaninov <citrin+git@citrin.ru>
Tue, 18 Aug 2020 17:45:30 +0000 (18:45 +0100)
committerAnton Yuzhaninov <citrin+git@citrin.ru>
Tue, 18 Aug 2020 17:45:30 +0000 (18:45 +0100)
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.

lualib/lua_selectors/extractors.lua
src/plugins/lua/clickhouse.lua

index d88eaa2164396155c0e58b64c80a66f3d6c0027b..4727b389c6e0a455c029eeb28dc116a178b02073 100644 (file)
@@ -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
index 734832d57a40976a4d72e8b628bf302ec96cf789..487997ddd7ff455228dc0a3afac2e9fdf1749521 100644 (file)
@@ -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())