#include "libserver/task.h"
#include "libstat/stat_api.h"
#include <math.h>
+#include <src/libserver/task.h>
/***
* @module rspamd_task
end
*/
LUA_FUNCTION_DEF (task, set_pre_result);
+
+/***
+ * @method task:has_pre_result()
+ * Returns true if task has some pre-result being set
+ *
+ * @return {boolean} true if task has some pre-result being set
+ */
+LUA_FUNCTION_DEF (task, has_pre_result);
/***
* @method task:append_message(message)
* Adds a message to scanning output.
LUA_INTERFACE_DEF (task, insert_result),
LUA_INTERFACE_DEF (task, adjust_result),
LUA_INTERFACE_DEF (task, set_pre_result),
+ LUA_INTERFACE_DEF (task, has_pre_result),
LUA_INTERFACE_DEF (task, append_message),
LUA_INTERFACE_DEF (task, has_urls),
LUA_INTERFACE_DEF (task, get_urls),
return 0;
}
+static gint
+lua_task_has_pre_result (lua_State * L)
+{
+ struct rspamd_task *task = lua_check_task (L, 1);
+
+ if (task) {
+ lua_pushboolean (L, task->pre_result.action != METRIC_ACTION_MAX);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
static gint
lua_task_append_message (lua_State * L)
{