/* We are not certain about the results during processing */
if (mres->passthrough_result == NULL) {
- for (i = 0; i < mres->nactions; i++) {
+ for (i = mres->nactions - 1; i >= 0; i--) {
action_lim = &mres->actions_limits[i];
sc = action_lim->cur_limit;
}
}
- if (set_action && selected_action == NULL) {
+ if (selected_action == NULL) {
selected_action = noaction->action;
}
}
action->flags |= RSPAMD_ACTION_HAM;
}
- HASH_ADD_STR (cfg->actions, name, action);
+ HASH_ADD_KEYPTR (hh, cfg->actions,
+ action->name, strlen (action->name), action);
}
/* Disable timeout */
act->action_type = METRIC_ACTION_CUSTOM;
}
- rspamd_actions_sort (cfg);
-
return TRUE;
}
const ucl_object_t *obj)
{
struct rspamd_action *act;
+ enum rspamd_action_type std_act;
const ucl_object_t *elt;
guint priority = ucl_object_get_priority (obj), obj_type;
}
}
+ /* Here are dragons:
+ * We have `canonical` name for actions, such as `soft reject` and
+ * configuration names for actions (used to be more convenient), such
+ * as `soft_reject`. Unfortunately, we must have heuristic for this
+ * variance of names.
+ */
+
+ if (rspamd_action_from_str (action_name, (gint *)&std_act)) {
+ action_name = rspamd_action_to_str (std_act);
+ }
+
HASH_FIND_STR (cfg->actions, action_name, act);
if (act) {
act->priority,
priority,
act->threshold);
- return rspamd_config_action_from_ucl (cfg, act, obj, priority);
+ if (rspamd_config_action_from_ucl (cfg, act, obj, priority)) {
+ rspamd_actions_sort (cfg);
+ }
+ else {
+ return FALSE;
+ }
}
else {
msg_info_config ("action %s has been already registered with "
act->name = rspamd_mempool_strdup (cfg->cfg_pool, action_name);
if (rspamd_config_action_from_ucl (cfg, act, obj, priority)) {
- HASH_ADD_STR (cfg->actions, name, act);
+ HASH_ADD_KEYPTR (hh, cfg->actions,
+ act->name, strlen (act->name), act);
+ rspamd_actions_sort (cfg);
}
else {
return FALSE;
}
if (action == NULL) {
+ struct rspamd_action *tmp;
+
+ HASH_ITER (hh, task->cfg->actions, action, tmp) {
+ msg_err ("known action: %s = %f", action->name, action->threshold);
+ }
+
return luaL_error (L, "unknown action %s", lua_tostring (L, 2));
}