]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Unify set_pre_result invocations
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 26 Oct 2021 13:53:33 +0000 (14:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 26 Oct 2021 13:53:33 +0000 (14:53 +0100)
src/lua/lua_task.c
src/plugins/lua/spamtrap.lua

index 3d81391b0429bb314583ecf5332d554340463842..bc9ab875079783aef224ea0608a9d8aa6d063b62 100644 (file)
@@ -2321,7 +2321,7 @@ lua_task_set_pre_result (lua_State * L)
                                                action->name, action->threshold);
                        }
 
-                       return luaL_error (L, "unknown action %s", lua_tostring (L, 2));
+                       return luaL_error (L, "unknown action %s", act_str);
                }
 
                if (module == NULL) {
index 0803d7d640d08d7b9ead13f87cccdd0d6f2bfd33..6147ad6800c9702d6fa40ec63a58a323a1d4b4f4 100644 (file)
@@ -63,23 +63,23 @@ local function spamtrap_cb(task)
     end
     task:insert_result(settings['symbol'], 1, rcpt)
 
-    if settings['action'] then
+    if settings.action then
       rspamd_logger.infox(task, 'spamtrap found: <%s>', rcpt)
+      local smtp_message
       if settings.smtp_message then
-        task:set_pre_result(settings['action'],
-          lua_util.template(settings.smtp_message, { rcpt = rcpt}), 'spamtrap')
+        smtp_message = lua_util.template(settings.smtp_message, { rcpt = rcpt})
       else
-        local smtp_message = 'unknown error'
+        smtp_message = 'unknown error'
         if settings.action == 'no action' then
           smtp_message = 'message accepted'
         elseif settings.action == 'reject' then
           smtp_message = 'message rejected'
         end
-        task:set_pre_result{action = settings['action'],
-                            message = smtp_message,
-                            module = 'spamtrap',
-                            flags = act_flags}
       end
+      task:set_pre_result{action = settings.action,
+                          message = smtp_message,
+                          module = 'spamtrap',
+                          flags = act_flags}
     end
   end