From: Vsevolod Stakhov Date: Thu, 3 Mar 2016 17:05:49 +0000 (+0000) Subject: [Feature] Allow to specify flags for metric symbols X-Git-Tag: 1.2.0~125 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b46282cc0f957e6a2549521175d965295cf7cbc2;p=rspamd.git [Feature] Allow to specify flags for metric symbols --- diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 59ca08864..53ad93049 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1277,7 +1277,7 @@ lua_config_set_metric_symbol (lua_State * L) { struct rspamd_config *cfg = lua_check_config (L, 1); const gchar *metric_name = DEFAULT_METRIC, *description = NULL, - *group = NULL, *name = NULL; + *group = NULL, *name = NULL, *flags_str = NULL; double weight; struct metric *metric; gboolean one_shot = FALSE; @@ -1290,9 +1290,9 @@ lua_config_set_metric_symbol (lua_State * L) if (lua_type (L, 2) == LUA_TTABLE) { if (!rspamd_lua_parse_table_arguments (L, 2, &err, "*name=S;score=N;description=S;" - "group=S;one_shot=B;metric=S;priority=N", + "group=S;one_shot=B;metric=S;priority=N;flags=S", &name, &weight, &description, - &group, &one_shot, &metric_name, &priority)) { + &group, &one_shot, &metric_name, &priority, &flags_str)) { msg_err_config ("bad arguments: %e", err); g_error_free (err); @@ -1326,6 +1326,15 @@ lua_config_set_metric_symbol (lua_State * L) flags |= RSPAMD_SYMBOL_FLAG_ONESHOT; } + if (flags_str) { + if (strstr (flags_str, "one_shot") != NULL) { + flags |= RSPAMD_SYMBOL_FLAG_ONESHOT; + } + else if (strstr (flags_str, "ignore") != NULL) { + flags |= RSPAMD_SYMBOL_FLAG_IGNORE; + } + } + if (metric == NULL) { msg_err_config ("metric named %s is not defined", metric_name); }