* Adds new settings id to be preprocessed
* @param cfg
* @param name
- * @param symbols_enabled
- * @param symbols_disabled
+ * @param symbols_enabled (ownership is transferred to callee)
+ * @param symbols_disabled (ownership is transferred to callee)
*/
void rspamd_config_register_settings_id (struct rspamd_config *cfg,
const gchar *name,
ucl_object_t *symbols_disabled);
/**
- * Finds settings id element and obtain reference count (must be unrefed by callee)
+ * Finds settings id element and obtain reference count (must be unrefed by caller)
* @param cfg
* @param id
* @return
*/
LUA_FUNCTION_DEF (config, get_group_symbols);
+/***
+ * @method rspamd_config:register_settings_id(name, symbols_enabled, symbols_disabled)
+ * Register new static settings id in config
+ * @param {string} name id name (not numeric!)
+ * @param {map|string->string} symbols_enabled map from symbol's name to boolean (currently)
+ * @param {map|string->string} symbols_disabled map from symbol's name to boolean (currently)
+ * @available 2.0+
+ */
+LUA_FUNCTION_DEF (config, register_settings_id);
+
/***
* @method rspamd_config:__newindex(name, callback)
* This metamethod is called if new indicies are added to the `rspamd_config` object.
LUA_INTERFACE_DEF (config, register_callback_symbol),
LUA_INTERFACE_DEF (config, register_callback_symbol_priority),
LUA_INTERFACE_DEF (config, register_dependency),
+ LUA_INTERFACE_DEF (config, register_settings_id),
LUA_INTERFACE_DEF (config, get_symbol_flags),
LUA_INTERFACE_DEF (config, add_symbol_flags),
LUA_INTERFACE_DEF (config, set_metric_symbol),
return 0;
}
+static gint
+lua_config_register_settings_id (lua_State *L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_config *cfg = lua_check_config (L, 1);
+ const gchar *settings_name = luaL_checkstring (L, 2);
+
+ if (cfg != NULL && settings_name) {
+ ucl_object_t *sym_enabled, *sym_disabled;
+
+ sym_enabled = ucl_object_lua_import (L, 3);
+
+ if (sym_enabled == NULL || ucl_object_type (sym_enabled) != UCL_ARRAY) {
+ ucl_object_unref (sym_enabled);
+
+ return luaL_error (L, "invalid symbols enabled");
+ }
+
+ sym_disabled = ucl_object_lua_import (L, 3);
+
+ if (sym_disabled == NULL || ucl_object_type (sym_disabled) != UCL_ARRAY) {
+ ucl_object_unref (sym_enabled);
+ ucl_object_unref (sym_disabled);
+
+ return luaL_error (L, "invalid symbols enabled");
+ }
+
+ rspamd_config_register_settings_id (cfg, settings_name, sym_enabled,
+ sym_disabled);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 0;
+}
+
static gint
lua_config_register_monitored (lua_State *L)
{