aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/backends/redis_backend.cxx4
-rw-r--r--src/libstat/backends/sqlite3_backend.c10
-rw-r--r--src/libstat/classifiers/lua_classifier.c14
-rw-r--r--src/libstat/stat_config.c2
-rw-r--r--src/libstat/stat_process.c15
5 files changed, 23 insertions, 22 deletions
diff --git a/src/libstat/backends/redis_backend.cxx b/src/libstat/backends/redis_backend.cxx
index 14e821029..630c895a2 100644
--- a/src/libstat/backends/redis_backend.cxx
+++ b/src/libstat/backends/redis_backend.cxx
@@ -218,7 +218,7 @@ gsize rspamd_redis_expand_object(const gchar *pattern,
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->cbref_user);
ptask = (struct rspamd_task **) lua_newuserdata(L, sizeof(struct rspamd_task *));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
if (lua_pcall(L, 1, 1, err_idx) != 0) {
msg_err_task("call to user extraction script failed: %s",
@@ -547,7 +547,7 @@ rspamd_redis_init(struct rspamd_stat_ctx *ctx,
if (ctx->event_loop) {
auto **pev_base = (struct ev_loop **) lua_newuserdata(L, sizeof(struct ev_loop *));
*pev_base = ctx->event_loop;
- rspamd_lua_setclass(L, "rspamd{ev_base}", -1);
+ rspamd_lua_setclass(L, rspamd_ev_base_classname, -1);
}
else {
lua_pushnil(L);
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c
index 2fd34d83f..68b52128f 100644
--- a/src/libstat/backends/sqlite3_backend.c
+++ b/src/libstat/backends/sqlite3_backend.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -177,7 +177,7 @@ rspamd_sqlite3_get_user(struct rspamd_stat_sqlite3_db *db,
lua_rawgeti(L, LUA_REGISTRYINDEX, db->cbref_user);
ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
if (lua_pcall(L, 1, 1, err_idx) != 0) {
msg_err_task("call to user extraction script failed: %s",
@@ -246,7 +246,7 @@ rspamd_sqlite3_get_language(struct rspamd_stat_sqlite3_db *db,
lua_rawgeti(L, LUA_REGISTRYINDEX, db->cbref_language);
ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
if (lua_pcall(L, 1, 1, err_idx) != 0) {
msg_err_task("call to language extraction script failed: %s",
diff --git a/src/libstat/classifiers/lua_classifier.c b/src/libstat/classifiers/lua_classifier.c
index b74330dca..30b2a0abd 100644
--- a/src/libstat/classifiers/lua_classifier.c
+++ b/src/libstat/classifiers/lua_classifier.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -145,10 +145,10 @@ lua_classifier_classify(struct rspamd_classifier *cl,
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->classify_ref);
ptask = lua_newuserdata(L, sizeof(*ptask));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
pcfg = lua_newuserdata(L, sizeof(*pcfg));
*pcfg = cl->cfg;
- rspamd_lua_setclass(L, "rspamd{classifier}", -1);
+ rspamd_lua_setclass(L, rspamd_classifier_classname, -1);
lua_createtable(L, tokens->len, 0);
@@ -200,10 +200,10 @@ lua_classifier_learn_spam(struct rspamd_classifier *cl,
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->learn_ref);
ptask = lua_newuserdata(L, sizeof(*ptask));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
pcfg = lua_newuserdata(L, sizeof(*pcfg));
*pcfg = cl->cfg;
- rspamd_lua_setclass(L, "rspamd{classifier}", -1);
+ rspamd_lua_setclass(L, rspamd_classifier_classname, -1);
lua_createtable(L, tokens->len, 0);
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 274804461..0e1ae5432 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -214,7 +214,7 @@ void rspamd_stat_init(struct rspamd_config *cfg, struct ev_loop *ev_base)
pcfg = lua_newuserdata(L, sizeof(*pcfg));
*pcfg = cfg;
- rspamd_lua_setclass(L, "rspamd{config}", -1);
+ rspamd_lua_setclass(L, rspamd_config_classname, -1);
if ((ret = lua_pcall(L, 1, 1, err_idx)) != 0) {
msg_err_config("call to gen_stat_tokens lua "
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index 8c1d8ff19..c1d194694 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,6 +21,7 @@
#include "libmime/images.h"
#include "libserver/html/html.h"
#include "lua/lua_common.h"
+#include "lua/lua_classnames.h"
#include "libserver/mempool_vars_internal.h"
#include "utlist.h"
#include <math.h>
@@ -54,7 +55,7 @@ rspamd_stat_tokenize_parts_metadata(struct rspamd_stat_ctx *st_ctx,
ptask = lua_newuserdata(L, sizeof(*ptask));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
if ((ret = lua_pcall(L, 1, 1, err_idx)) != 0) {
msg_err_task("call to stat_tokens lua "
@@ -210,7 +211,7 @@ rspamd_stat_classifier_is_skipped(struct rspamd_task *task,
/* Push task and two booleans: is_spam and is_unlearn */
struct rspamd_task **ptask = lua_newuserdata(L, sizeof(*ptask));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
if (is_learn) {
lua_pushboolean(L, is_spam);
@@ -1063,7 +1064,7 @@ rspamd_stat_check_autolearn(struct rspamd_task *task)
ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
if (lua_pcall(L, 1, 1, err_idx) != 0) {
msg_err_task("call to autolearn script failed: "
@@ -1118,7 +1119,7 @@ rspamd_stat_check_autolearn(struct rspamd_task *task)
ptask = lua_newuserdata(L, sizeof(struct rspamd_task *));
*ptask = task;
- rspamd_lua_setclass(L, "rspamd{task}", -1);
+ rspamd_lua_setclass(L, rspamd_task_classname, -1);
/* Push the whole object as well */
ucl_object_push_lua(L, obj, true);