]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Implement task to object conversion method
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Oct 2021 10:32:26 +0000 (11:32 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Oct 2021 10:32:26 +0000 (11:32 +0100)
lualib/lua_mime.lua

index f84cc4d4e076e21b3ed157022fa0510cc66ee89f..a57c2181ea7bce81a929bbcb525523f603625bee 100644 (file)
@@ -581,6 +581,24 @@ exports.message_to_ucl = function(task)
   result.size = task:get_size()
   result.digest = task:get_digest()
 
+  result.headers = task:get_headers(true) or {}
+
+  local parts = task:get_parts() or {}
+  result.parts = {}
+  for _,part in ipairs(parts) do
+    local l = part:get_length()
+    if l > 0 then
+      local p = {}
+      p.size = l
+      p.type = string.format('%s/%s', part:get_type())
+      p.detected_type = string.format('%s/%s', part:get_detected_type())
+      p.filename = part:get_filename()
+      p.content = part:get_content()
+      p.headers = part:get_headers(true) or {}
+      table.insert(result.parts, p)
+    end
+  end
+
   return result
 end