aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-10-15 11:32:26 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-10-15 11:32:26 +0100
commitf2298a00267d69c4ee03c15fcf800b4e71105192 (patch)
tree83eac179e4f4ea88b86aa6b686997ff3072e47b3 /lualib
parent5512bbb2c7506b5fea638bc2f4d242362b8976c5 (diff)
downloadrspamd-f2298a00267d69c4ee03c15fcf800b4e71105192.tar.gz
rspamd-f2298a00267d69c4ee03c15fcf800b4e71105192.zip
[Minor] Implement task to object conversion method
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_mime.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index f84cc4d4e..a57c2181e 100644
--- a/lualib/lua_mime.lua
+++ b/lualib/lua_mime.lua
@@ -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