aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-01-23 21:52:00 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-01-23 21:52:00 +0000
commit16d8e1ef572d5ee720015672b9afb4f168fbb94f (patch)
treee1ed5ce5c731a2ebff5cd00dada2e7478a95c02d /src/libserver
parentc978a76a0fbaed446b672be38596785f4bc468e9 (diff)
downloadrspamd-16d8e1ef572d5ee720015672b9afb4f168fbb94f.tar.gz
rspamd-16d8e1ef572d5ee720015672b9afb4f168fbb94f.zip
[Feature] Add `thresholds` field to the scan result
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/protocol.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 380d80134..3708d823f 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1213,7 +1213,7 @@ rspamd_scan_result_ucl (struct rspamd_task *task,
if (pr) {
if (pr->message && !(pr->flags & RSPAMD_PASSTHROUGH_NO_SMTP_MESSAGE)) {
- /* Add smtp message if it does not exists: see #3269 for details */
+ /* Add smtp message if it does not exist: see #3269 for details */
if (ucl_object_lookup(task->messages, "smtp_message") == NULL) {
ucl_object_insert_key(task->messages,
ucl_object_fromstring_common(pr->message, 0, UCL_STRING_RAW),
@@ -1268,6 +1268,21 @@ rspamd_scan_result_ucl (struct rspamd_task *task,
/* Now handle symbols */
if (task->cmd != CMD_CHECK) {
+ /* Insert actions thresholds */
+ ucl_object_t *actions_obj = ucl_object_typed_new (UCL_OBJECT);
+
+ for (int i = task->result->nactions - 1; i >= 0; i --) {
+ struct rspamd_action_config *action_lim = &task->result->actions_config[i];
+
+ if (!isnan (action_lim->cur_limit) &&
+ !(action_lim->action->flags & (RSPAMD_ACTION_NO_THRESHOLD|RSPAMD_ACTION_HAM))) {
+ ucl_object_insert_key(actions_obj, ucl_object_fromdouble(action_lim->cur_limit),
+ action_lim->action->name, 0, true);
+ }
+ }
+
+ ucl_object_insert_key(obj, actions_obj, "thresholds", 0, false);
+
/* For checkv2 we insert symbols as a separate object */
obj = ucl_object_typed_new (UCL_OBJECT);
}