From: Vsevolod Stakhov Date: Thu, 21 Jul 2016 08:14:36 +0000 (+0100) Subject: [Feature] Allow underscore separated names in settings X-Git-Tag: 1.3.0~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9f7ac8960eb18e4cc152cd52f102f621010b9c36;p=rspamd.git [Feature] Allow underscore separated names in settings --- diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 6aaa19aaf..5b998406f 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -330,6 +330,29 @@ rspamd_action_to_str (enum rspamd_metric_action action) return "unknown action"; } +const gchar * +rspamd_action_to_str_alt (enum rspamd_metric_action action) +{ + switch (action) { + case METRIC_ACTION_REJECT: + return "reject"; + case METRIC_ACTION_SOFT_REJECT: + return "soft_reject"; + case METRIC_ACTION_REWRITE_SUBJECT: + return "rewrite_subject"; + case METRIC_ACTION_ADD_HEADER: + return "add_header"; + case METRIC_ACTION_GREYLIST: + return "greylist"; + case METRIC_ACTION_NOACTION: + return "no action"; + case METRIC_ACTION_MAX: + return "invalid max action"; + } + + return "unknown action"; +} + enum rspamd_metric_action rspamd_check_action_metric (struct rspamd_task *task, struct metric_result *mres) { diff --git a/src/libmime/filter.h b/src/libmime/filter.h index 280c54879..6c61f5d6f 100644 --- a/src/libmime/filter.h +++ b/src/libmime/filter.h @@ -93,6 +93,7 @@ gboolean rspamd_action_from_str (const gchar *data, gint *result); * Return textual representation of action enumeration */ const gchar * rspamd_action_to_str (enum rspamd_metric_action action); +const gchar * rspamd_action_to_str_alt (enum rspamd_metric_action action); /* * Get action for specific metric diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index a3e3b0564..d18eaa4ea 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -2822,7 +2822,8 @@ lua_task_set_settings (lua_State *L) } for (i = 0; i < METRIC_ACTION_MAX; i++) { - elt = ucl_object_lookup (act, rspamd_action_to_str (i)); + elt = ucl_object_lookup_any (act, rspamd_action_to_str (i), + rspamd_action_to_str_alt (i), NULL); if (elt) { mres->actions_limits[i] = ucl_object_todouble (elt);