]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some issues with lua scripts invocation
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 4 Mar 2020 19:36:11 +0000 (19:36 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 4 Mar 2020 20:04:00 +0000 (20:04 +0000)
src/fuzzy_storage.c

index 107cf79442c7f89268a559bb89262740056073f8..b6d7d8ee7c6019392574331c87221f3a620f48f1 100644 (file)
@@ -796,7 +796,7 @@ rspamd_fuzzy_check_callback (struct rspamd_fuzzy_reply *result, void *ud)
                /* Preallocate stack (small opt) */
                lua_checkstack (L, err_idx + 9);
                /* function */
-               lua_rawgeti (L, LUA_REGISTRYINDEX, session->ctx->lua_pre_handler_cbref);
+               lua_rawgeti (L, LUA_REGISTRYINDEX, session->ctx->lua_post_handler_cbref);
                /* client IP */
                rspamd_lua_ip_push (L, session->addr);
                /* client command */
@@ -825,6 +825,7 @@ rspamd_fuzzy_check_callback (struct rspamd_fuzzy_reply *result, void *ud)
                         * if it is true, then we need to read the former ones:
                         * 2-nd will be reply code
                         * 3-rd will be probability (or 0.0 if missing)
+                        * 4-th value is flag (or default flag if missing)
                         */
                        ret = lua_toboolean (L, err_idx + 1);
 
@@ -839,6 +840,10 @@ rspamd_fuzzy_check_callback (struct rspamd_fuzzy_reply *result, void *ud)
                                        result->v1.prob = 0.0f;
                                }
 
+                               if (lua_isnumber (L, err_idx + 4)) {
+                                       result->v1.flag = lua_tointeger (L, err_idx + 4);
+                               }
+
                                lua_settop (L, 0);
                                rspamd_fuzzy_make_reply (cmd, result, session, encrypted, is_shingle);
                                REF_RELEASE (session);