aboutsummaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2018-03-19 19:48:04 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2018-03-19 19:48:04 +0300
commit0c78ea6747f9edaca63d0e122dca1e3b53587ec6 (patch)
tree2c6f1d0c224da08655965b0590a8e27180f0f6ec /src/controller.c
parentbef67cce03e24465a7f7ea1ed2689727fd83a859 (diff)
downloadrspamd-0c78ea6747f9edaca63d0e122dca1e3b53587ec6.tar.gz
rspamd-0c78ea6747f9edaca63d0e122dca1e3b53587ec6.zip
[Fix] Never hide actions from WebUI `configuration` tab
- Never hide actions (fixes #1910) - Allow to disable actions from WebUI - Add `rewrite subject` action to `configuration` tab
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/controller.c b/src/controller.c
index 09b446e8c..1685f7eb0 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -868,15 +868,13 @@ rspamd_controller_handle_actions (struct rspamd_http_connection_entry *conn_ent,
/* Get actions for default metric */
for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
act = &session->cfg->actions[i];
- if (act->score >= 0) {
- obj = ucl_object_typed_new (UCL_OBJECT);
- ucl_object_insert_key (obj,
- ucl_object_fromstring (rspamd_action_to_str (
- act->action)), "action", 0, false);
- ucl_object_insert_key (obj, ucl_object_fromdouble (
- act->score), "value", 0, false);
- ucl_array_append (top, obj);
- }
+ obj = ucl_object_typed_new (UCL_OBJECT);
+ ucl_object_insert_key (obj,
+ ucl_object_fromstring (rspamd_action_to_str (
+ act->action)), "action", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromdouble (
+ act->score), "value", 0, false);
+ ucl_array_append (top, obj);
}
rspamd_controller_send_ucl (conn_ent, top);
@@ -2159,8 +2157,8 @@ rspamd_controller_handle_saveactions (
obj = ucl_parser_get_object (parser);
ucl_parser_free (parser);
- if (obj->type != UCL_ARRAY || obj->len != 3) {
- msg_err_session ("input is not an array of 3 elements");
+ if (obj->type != UCL_ARRAY || obj->len != 4) {
+ msg_err_session ("input is not an array of 4 elements");
rspamd_controller_send_error (conn_ent, 400, "Cannot parse input");
ucl_object_unref (obj);
return 0;
@@ -2168,19 +2166,20 @@ rspamd_controller_handle_saveactions (
it = ucl_object_iterate_new (obj);
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
cur = ucl_object_iterate_safe (it, TRUE);
- if (cur == NULL) {
- break;
- }
+
switch (i) {
case 0:
act = METRIC_ACTION_REJECT;
break;
case 1:
- act = METRIC_ACTION_ADD_HEADER;
+ act = METRIC_ACTION_REWRITE_SUBJECT;
break;
case 2:
+ act = METRIC_ACTION_ADD_HEADER;
+ break;
+ case 3:
act = METRIC_ACTION_GREYLIST;
break;
}
@@ -2193,7 +2192,6 @@ rspamd_controller_handle_saveactions (
score = ucl_object_todouble (cur);
}
-
if ((isnan (session->cfg->actions[act].score) != isnan (score)) ||
(session->cfg->actions[act].score != score)) {
add_dynamic_action (ctx->cfg, DEFAULT_METRIC, act, score);