]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to specify flags for metric symbols
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 3 Mar 2016 17:05:49 +0000 (17:05 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 3 Mar 2016 17:05:49 +0000 (17:05 +0000)
src/lua/lua_config.c

index 59ca0886485b89aad5e059e8dbd81f461a8388ea..53ad93049452254b4447fbf7cd28e6e2ca8a66aa 100644 (file)
@@ -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);
                }