diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-10-22 20:56:31 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-10-22 20:56:31 +0400 |
commit | 11e2283597d33b6decfbe453c877af1a5d5488f5 (patch) | |
tree | 09731378a67e40d157251cecf372d78264b79281 /src/settings.c | |
parent | 8c7ee775ff127e018ebb5d8768b652e7c1d539f1 (diff) | |
download | rspamd-11e2283597d33b6decfbe453c877af1a5d5488f5.tar.gz rspamd-11e2283597d33b6decfbe453c877af1a5d5488f5.zip |
Add special cases in metric actions: reject_score and spam_score for managing metric scores directly.
Diffstat (limited to 'src/settings.c')
-rw-r--r-- | src/settings.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/settings.c b/src/settings.c index edfc5a21d..cbf73ddd4 100644 --- a/src/settings.c +++ b/src/settings.c @@ -227,6 +227,7 @@ json_fin_cb (memory_pool_t * pool, struct map_cb_data *data) act_it = json_object_iter (it_val); while (act_it) { act_value = json_object_iter_value (act_it); + if (it_val && json_is_number (act_value)) { if (check_action_str (json_object_iter_key (act_it), &j)) { new_act = g_malloc (sizeof (struct metric_action)); @@ -234,6 +235,21 @@ json_fin_cb (memory_pool_t * pool, struct map_cb_data *data) new_act->score = json_number_value (act_value); cur_act = g_list_prepend (cur_act, new_act); } + else { + /* Special cases */ + if (g_ascii_strcasecmp (json_object_iter_key (act_it), "spam_score") == 0) { + score = g_malloc (sizeof (double)); + *score = json_number_value (act_it); + g_hash_table_insert (cur_settings->metric_scores, + g_strdup (json_object_iter_key (act_it)), score); + } + else if (g_ascii_strcasecmp (json_object_iter_key (act_it), "reject_score") == 0) { + score = g_malloc (sizeof (double)); + *score = json_number_value (act_it); + g_hash_table_insert (cur_settings->reject_scores, + g_strdup (json_object_iter_key (act_it)), score); + } + } } act_it = json_object_iter_next (it_val, act_it); } |