commit 4f40211: [Minor] Lua_task: Add compatibility knobs for set_pre_result
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Jan 23 14:28:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-01-23 14:27:11 +0000
URL: https://github.com/rspamd/rspamd/commit/4f402113c491ac3a4b08c914416b976e04deb239 (HEAD -> master)
[Minor] Lua_task: Add compatibility knobs for set_pre_result
---
src/lua/lua_task.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index e8746f2bd..2606478d1 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1666,7 +1666,19 @@ lua_task_set_pre_result (lua_State * L)
}
if (lua_type (L, 2) == LUA_TSTRING) {
- action = rspamd_config_get_action (task->cfg, lua_tostring (L, 2));
+ const gchar *act_name = lua_tostring (L, 2);
+ gint internal_type;
+
+ if (strcmp (act_name, "accept") == 0) {
+ /* Compatibility! */
+ act_name = "no action";
+ }
+ else if (rspamd_action_from_str (act_name, &internal_type)) {
+ /* Compatibility! */
+ act_name = rspamd_action_to_str (internal_type);
+ }
+
+ action = rspamd_config_get_action (task->cfg, act_name);
}
else {
return luaL_error (L, "invalid arguments");
@@ -1676,7 +1688,8 @@ lua_task_set_pre_result (lua_State * L)
struct rspamd_action *tmp;
HASH_ITER (hh, task->cfg->actions, action, tmp) {
- msg_err ("known action: %s = %f", action->name, action->threshold);
+ msg_err_task ("known defined action: %s = %f",
+ action->name, action->threshold);
}
return luaL_error (L, "unknown action %s", lua_tostring (L, 2));
More information about the Commits
mailing list