aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/learn_cache
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-01-15 15:25:23 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-01-15 15:25:23 +0000
commit7b9dd286eae49337eaebdd41cfbc5d3569a1e585 (patch)
treea5a99fa21cf480a699fc53b51dfdb87b5aeb9e5e /src/libstat/learn_cache
parent5d861d8dd15d7115bdffaf60e7b3610f080ba6be (diff)
downloadrspamd-7b9dd286eae49337eaebdd41cfbc5d3569a1e585.tar.gz
rspamd-7b9dd286eae49337eaebdd41cfbc5d3569a1e585.zip
[Minor] Fix scripts invocation
Diffstat (limited to 'src/libstat/learn_cache')
-rw-r--r--src/libstat/learn_cache/redis_cache.cxx34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/libstat/learn_cache/redis_cache.cxx b/src/libstat/learn_cache/redis_cache.cxx
index e53bd4df0..86a6a35d4 100644
--- a/src/libstat/learn_cache/redis_cache.cxx
+++ b/src/libstat/learn_cache/redis_cache.cxx
@@ -217,22 +217,28 @@ static gint
rspamd_stat_cache_checked(lua_State *L)
{
auto *task = lua_check_task(L, 1);
- auto val = lua_tointeger(L, 2);
-
- if ((val > 0 && (task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM)) ||
- (val < 0 && (task->flags & RSPAMD_TASK_FLAG_LEARN_HAM))) {
- /* Already learned */
- msg_info_task("<%s> has been already "
- "learned as %s, ignore it",
- MESSAGE_FIELD(task, message_id),
- (task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM) ? "spam" : "ham");
- task->flags |= RSPAMD_TASK_FLAG_ALREADY_LEARNED;
- }
- else if (val != 0) {
- /* Unlearn flag */
- task->flags |= RSPAMD_TASK_FLAG_UNLEARN;
+ auto res = lua_toboolean(L, 2);
+
+ if (res) {
+ auto val = lua_tointeger(L, 3);
+
+ if ((val > 0 && (task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM)) ||
+ (val < 0 && (task->flags & RSPAMD_TASK_FLAG_LEARN_HAM))) {
+ /* Already learned */
+ msg_info_task("<%s> has been already "
+ "learned as %s, ignore it",
+ MESSAGE_FIELD(task, message_id),
+ (task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM) ? "spam" : "ham");
+ task->flags |= RSPAMD_TASK_FLAG_ALREADY_LEARNED;
+ }
+ else if (val != 0) {
+ /* Unlearn flag */
+ task->flags |= RSPAMD_TASK_FLAG_UNLEARN;
+ }
}
+ /* Ignore errors for now, as we can do nothing about them at the moment */
+
return 0;
}