enum rspamd_symbol_insert_flags flags,
struct rspamd_scan_result *result);
-#define rspamd_task_insert_result_single(task, symbol, flag, opts) \
- rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_SINGLE, NULL)
-#define rspamd_task_insert_result(task, symbol, flag, opts) \
- rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_DEFAULT, NULL)
+#define rspamd_task_insert_result_single(task, symbol, weight, opts) \
+ rspamd_task_insert_result_full ((task), (symbol), (weight), (opts), RSPAMD_SYMBOL_INSERT_SINGLE, NULL)
+#define rspamd_task_insert_result(task, symbol, weight, opts) \
+ rspamd_task_insert_result_full ((task), (symbol), (weight), (opts), RSPAMD_SYMBOL_INSERT_DEFAULT, NULL)
/**
* Removes a symbol from a specific symbol result
struct rspamd_cryptobox_keypair *local_key;
struct rspamd_cryptobox_pubkey *peer_key;
double max_score;
+ double weight_threshold;
gboolean read_only;
gboolean skip_unknown;
gboolean no_share;
(rspamd_mempool_destruct_t)g_hash_table_unref,
rule->mappings);
rule->read_only = FALSE;
+ rule->weight_threshold = NAN;
return rule;
}
rule->algorithm_str);
}
+ if ((value = ucl_object_lookup (obj, "weight_threshold")) != NULL) {
+ rule->weight_threshold = ucl_object_todouble (value);
+ }
+
/*
* Process rule in Lua
*/
}
static void
-fuzzy_insert_metric_results (struct rspamd_task *task, GPtrArray *results)
+fuzzy_insert_metric_results (struct rspamd_task *task, struct fuzzy_rule *rule,
+ GPtrArray *results)
{
struct fuzzy_client_result *res;
guint i;
}
}
- rspamd_task_insert_result_single (task, res->symbol,
- res->score * mult, res->option);
+ gdouble weight = res->score * mult;
+
+ if (!isnan (rule->weight_threshold)) {
+ if (weight >= rule->weight_threshold) {
+ rspamd_task_insert_result_single (task, res->symbol,
+ weight, res->option);
+ }
+ else {
+ msg_info_task ("%s is not added: weight=%.4f below threshold",
+ res->symbol, weight);
+ }
+ }
+ else {
+ rspamd_task_insert_result_single (task, res->symbol,
+ weight, res->option);
+ }
}
}
}
if (nreplied == session->commands->len) {
- fuzzy_insert_metric_results (session->task, session->results);
+ fuzzy_insert_metric_results (session->task, session->rule, session->results);
+
if (session->item) {
rspamd_symcache_item_async_dec_check (session->task, session->item, M);
}
+
rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session);
return TRUE;