summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-22 16:22:04 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-22 16:22:29 +0000
commit43c67de7e23f2018a6cc51a9d187aec9ad928387 (patch)
tree7668ddb428a36e9b24ff4d136a15ba88d7787764 /lualib
parent01b4b738a7dc7ec64c1bf2451ca5e1bfa5961ceb (diff)
downloadrspamd-43c67de7e23f2018a6cc51a9d187aec9ad928387.tar.gz
rspamd-43c67de7e23f2018a6cc51a9d187aec9ad928387.zip
[Minor] Lua_selectors: Add languages selector
Issue: #2763
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_selectors.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 0a02edca9..b678ef179 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -199,6 +199,27 @@ the second optional argument is optional hash type (`blake2`, `sha256`, `sha1`,
end,
['description'] = 'Get all attachments files',
},
+ -- Get languages for text parts
+ ['languages'] = {
+ ['get_value'] = function(task)
+ local text_parts = task:get_text_parts() or E
+ local languages = {}
+
+ for _,p in ipairs(text_parts) do
+ local lang = p:get_language()
+ if lang then
+ table.insert(languages, lang)
+ end
+ end
+
+ if #languages > 0 then
+ return languages,'string_list'
+ end
+
+ return nil
+ end,
+ ['description'] = 'Get languages for text parts',
+ },
-- Get helo value
['helo'] = {
['get_value'] = function(task)