diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-12-10 14:57:22 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-12-10 14:57:22 +0000 |
commit | 1b78893987deb9913e0cd7e5534c592f4a3ad1a9 (patch) | |
tree | 955eaca6c65dffb4419d885445781b07f40554f6 | |
parent | 7d3200169892d35ac3f9ec4234a71828041bf521 (diff) | |
download | rspamd-1b78893987deb9913e0cd7e5534c592f4a3ad1a9.tar.gz rspamd-1b78893987deb9913e0cd7e5534c592f4a3ad1a9.zip |
[Minor] GPT: use lua_mime routine to select text part
-rw-r--r-- | src/plugins/lua/gpt.lua | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 014f47d72..10cff0fb5 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -56,6 +56,7 @@ end local lua_util = require "lua_util" local rspamd_http = require "rspamd_http" local rspamd_logger = require "rspamd_logger" +local lua_mime = require "lua_mime" local ucl = require "ucl" local fun = require "fun" @@ -128,19 +129,7 @@ local function default_condition(task) end -- Check if we have text at all - local mp = task:get_parts() or {} - local sel_part - for _, mime_part in ipairs(mp) do - if mime_part:is_text() then - local part = mime_part:get_text() - if part:is_html() then - -- We prefer html content - sel_part = part - elseif not sel_part then - sel_part = part - end - end - end + local sel_part = lua_mime.get_displayed_text_part(task) if not sel_part then return false, 'no text part found' |