]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add time to the selectors spec
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 21 Aug 2018 11:36:58 +0000 (12:36 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 21 Aug 2018 11:36:58 +0000 (12:36 +0100)
lualib/lua_selectors.lua

index 096490ef823becde84f6ac040156664be75b8652..69a20b9c49ac82829599013f8a16c0c5c4a49642 100644 (file)
@@ -207,6 +207,25 @@ local extractors = {
         return tostring(hdr)
       end
 
+      return nil
+    end
+  },
+  -- Get task date, optionally formatted
+  ['time'] = {
+    ['type'] = 'string',
+    ['get_value'] = function(task, _, args)
+      local what = args[1] or 'message'
+      local dt = task:get_date{format = what, gmt = true}
+
+      if dt then
+        if args[2] then
+          -- Should be in format !xxx, as dt is in GMT
+          return os.date(args[2], dt)
+        end
+
+        return tostring(dt)
+      end
+
       return nil
     end
   }