]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] More hacks to deal with old configs
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 5 Nov 2017 13:25:41 +0000 (13:25 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 5 Nov 2017 13:25:41 +0000 (13:25 +0000)
lualib/rspamd_config_transform.lua

index cf19ca3eda613afed856bb73a94f06c278872899..006c22d45e4a4eb010d11c6cc07e40a950b9b6c9 100644 (file)
@@ -51,9 +51,9 @@ local function metric_pairs(t)
         else
           -- Very tricky to distinguish:
           -- group {name = "foo" ... } + group "blah" { ... }
-          for k,v in pairs(tbl) do
-            if type(k) ~= 'number' then
-              table.insert(keys, {k, v})
+          for gr_name,gr in pairs(v) do
+            if type(gr_name) ~= 'number' then
+              table.insert(keys, {gr_name, gr})
             end
           end
         end
@@ -159,10 +159,6 @@ local function test_groups(groups)
 end
 
 local function convert_metric(cfg, metric)
-  if type(metric[1]) == 'table' then
-    logger.warnx("multiple metrics have never been supported")
-    metric = metric[1]
-  end
   if metric.actions then
     cfg.actions = override_defaults(metric.actions)
     logger.warnx("overriding actions from the legacy metric settings")
@@ -195,7 +191,9 @@ return function(cfg)
   local ret = false
 
   if cfg['metric'] then
-    cfg = convert_metric(cfg, cfg.metric)
+    for _, v in metric_pairs(cfg.metric) do
+      cfg = convert_metric(cfg, v)
+    end
     ret = true
   end