]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix emails module configuration
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Jul 2017 18:38:21 +0000 (19:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Jul 2017 18:38:21 +0000 (19:38 +0100)
src/plugins/lua/emails.lua

index cd632b85e21ac6aca0203277de6c3e521a271115..97378924fce2c07d23eea32ed3ba018538c88a80 100644 (file)
@@ -147,36 +147,32 @@ local function gen_check_emails(rule)
   end
 end
 
-local opts =  rspamd_config:get_all_opt('emails', 'rule')
+local opts = rspamd_config:get_module_opt('emails', 'rules')
 if opts and type(opts) == 'table' then
-  local r = opts['rule']
-
-  if r then
-    for k,v in pairs(r) do
-      local rule = v
-      if not rule['symbol'] then
-        rule['symbol'] = k
-      end
+  for k,v in pairs(opts) do
+    local rule = v
+    if not rule['symbol'] then
+      rule['symbol'] = k
+    end
 
-      if not rule['delimiter'] then
-        rule['delimiter'] = "@"
-      end
+    if not rule['delimiter'] then
+      rule['delimiter'] = "@"
+    end
 
-      if rule['map'] then
-        rule['name'] = rule['map']
-        rule['map'] = rspamd_config:add_map({
-           url = rule['name'],
-           description = string.format('Emails rule %s', rule['symbol']),
-           type = 'regexp'
-        })
-      end
-      if not rule['symbol'] or (not rule['map'] and not rule['dnsbl']) then
-        logger.errx(rspamd_config, 'incomplete rule')
-      else
-        table.insert(rules, rule)
-        logger.infox(rspamd_config, 'add emails rule %s',
-          rule['dnsbl'] or rule['name'] or '???')
-      end
+    if rule['map'] then
+      rule['name'] = rule['map']
+      rule['map'] = rspamd_config:add_map({
+        url = rule['name'],
+        description = string.format('Emails rule %s', rule['symbol']),
+        type = 'regexp'
+      })
+    end
+    if not rule['symbol'] or (not rule['map'] and not rule['dnsbl']) then
+      logger.errx(rspamd_config, 'incomplete rule: %s', rule)
+    else
+      table.insert(rules, rule)
+      logger.infox(rspamd_config, 'add emails rule %s',
+        rule['dnsbl'] or rule['name'] or '???')
     end
   end
 end