Browse Source

[Rspamd] domain-wide-footer add jinja templating

FreddleSpl0it 2 years ago
parent
commit
5ae9605e77
1 changed files with 10 additions and 0 deletions
  1. 10 0
      data/conf/rspamd/lua/rspamd.local.lua

+ 10 - 0
data/conf/rspamd/lua/rspamd.local.lua

@@ -505,6 +505,7 @@ rspamd_config:register_symbol({
   type = 'prefilter',
   type = 'prefilter',
   callback = function(task)
   callback = function(task)
     local lua_mime = require "lua_mime"
     local lua_mime = require "lua_mime"
+    local lua_util = require "lua_util"
     local rspamd_logger = require "rspamd_logger"
     local rspamd_logger = require "rspamd_logger"
     local rspamd_redis = require "rspamd_redis"
     local rspamd_redis = require "rspamd_redis"
     local ucl = require "ucl"
     local ucl = require "ucl"
@@ -542,6 +543,15 @@ rspamd_config:register_symbol({
 
 
           if footer and type(footer) == "table" and (footer.html or footer.plain) then
           if footer and type(footer) == "table" and (footer.html or footer.plain) then
             rspamd_logger.infox(rspamd_config, "found domain wide footer for user %s: html=%s, plain=%s", uname, footer.html, footer.plain)
             rspamd_logger.infox(rspamd_config, "found domain wide footer for user %s: html=%s, plain=%s", uname, footer.html, footer.plain)
+            local replacements = {
+              email = uname
+            }
+            if footer.html then
+              footer.html = lua_util.jinja_template(footer.html, replacements, true)
+            end
+            if footer.plain then
+              footer.plain = lua_util.jinja_template(footer.plain, replacements, true)
+            end
   
   
             -- add footer
             -- add footer
             local out = {}
             local out = {}