aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-02 13:38:57 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-02 13:38:57 +0000
commita1bdb1f4f56ea6b3877e9c9d030d085728f0d566 (patch)
tree58ad60e9c78d8dfbcd06f5d314a5c21465f8f1e2 /src/lua
parent99488d5a2a601f4a4ae30036b07189ff9c17ed3c (diff)
downloadrspamd-a1bdb1f4f56ea6b3877e9c9d030d085728f0d566.tar.gz
rspamd-a1bdb1f4f56ea6b3877e9c9d030d085728f0d566.zip
[Rework] Make rspamd protocol messages useful
Each message is now represented by a string and category, so messages in metric is an UCL object of the following format: { "category": "string" } The significant category is `smtp_message` which should be used by rmilter to send a custom SMTP reply to a client.
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_task.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index e686876f7..dcbdfc9e1 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1093,7 +1093,9 @@ lua_task_set_pre_result (lua_State * L)
action_str = rspamd_mempool_strdup (task->task_pool,
luaL_checkstring (L, 3));
task->pre_result.str = action_str;
- task->messages = g_list_prepend (task->messages, action_str);
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring (action_str), "smtp_message", 0,
+ false);
}
else {
task->pre_result.str = "unknown";
@@ -1123,12 +1125,19 @@ static gint
lua_task_append_message (lua_State * L)
{
struct rspamd_task *task = lua_check_task (L, 1);
- gchar *message;
+ const gchar *message = luaL_checkstring (L, 2), *category;
if (task != NULL) {
- message= rspamd_mempool_strdup (task->task_pool,
- luaL_checkstring (L, 2));
- task->messages = g_list_prepend (task->messages, message);
+ if (lua_type (L, 3) == LUA_TSTRING) {
+ category = luaL_checkstring (L, 3);
+ }
+ else {
+ category = "unknown";
+ }
+
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring (message), category, 0,
+ true);
}
else {
return luaL_error (L, "invalid arguments");