diff = NAN;
break;
- } else if (gr_score) {
+ }
+ else if (gr_score) {
*gr_score += cur_diff;
if (cur_diff < diff) {
return res;
}
+struct rspamd_symbol_result* rspamd_task_remove_symbol_result (
+ struct rspamd_task *task,
+ const gchar *symbol,
+ struct rspamd_scan_result *result)
+{
+ struct rspamd_symbol_result *res = NULL;
+ khiter_t k;
+
+ if (result == NULL) {
+ /* Use default result */
+ result = task->result;
+ }
+
+ k = kh_get (rspamd_symbols_hash, result->symbols, symbol);
+
+ if (k != kh_end (result->symbols)) {
+ res = &kh_value (result->symbols, k);
+
+ if (!isnan (res->score)) {
+ /* Remove score from the result */
+ result->score -= res->score;
+
+ /* Also check the group limit */
+ if (result->sym_groups && res->sym) {
+ struct rspamd_symbol_group *gr;
+ gint i;
+
+ PTR_ARRAY_FOREACH (res->sym->groups, i, gr) {
+ gdouble *gr_score;
+
+ k = kh_get (rspamd_symbols_group_hash,
+ result->sym_groups, gr);
+
+ if (k != kh_end (result->sym_groups)) {
+ gr_score = &kh_value (result->sym_groups, k);
+
+ if (gr_score) {
+ *gr_score -= res->score;
+ }
+ }
+ }
+ }
+ }
+
+ kh_del (rspamd_symbols_hash, result->symbols, k);
+ }
+ else {
+ return NULL;
+ }
+
+ return res;
+}
+
void
rspamd_task_symbol_result_foreach (struct rspamd_task *task,
struct rspamd_scan_result *result, GHFunc func,
#define rspamd_task_insert_result(task, symbol, flag, opts) \
rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_DEFAULT, NULL)
-
+/**
+ * Removes a symbol from a specific symbol result
+ * @param task
+ * @param symbol
+ * @param result
+ * @return
+ */
+struct rspamd_symbol_result* rspamd_task_remove_symbol_result (
+ struct rspamd_task *task,
+ const gchar *symbol,
+ struct rspamd_scan_result *result);
/**
* Adds new option to symbol
* @param task