File: deps.lua

package info (click to toggle)
rspamd 3.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,056 kB
  • sloc: ansic: 243,746; cpp: 105,657; javascript: 29,539; asm: 2,512; perl: 2,440; pascal: 1,625; python: 1,274; sql: 313; sh: 281; makefile: 140; xml: 74
file content (30 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local cb = function(task)
  task:insert_result('TOP', 1.0)
end

local cb_dep1 = function(task)
  if task:get_symbol('TOP') then
    task:insert_result('DEP1', 1.0)
  end
end

local cb_gen = function(num)
  local cb_dep = function(task)
    if task:get_symbol('DEP' .. tostring(num)) then
      task:insert_result('DEP' .. tostring(num + 1), 1.0)
    end
  end

  return cb_dep
end

local id = rspamd_config:register_callback_symbol(1.0, cb)
rspamd_config:register_virtual_symbol('TOP', 1.0, id)

rspamd_config:register_symbol('DEP1', 1.0, cb_dep1)
rspamd_config:register_dependency('DEP1', 'TOP')

for i = 2, 10 do
  rspamd_config:register_symbol('DEP' .. tostring(i), 1.0, cb_gen(i - 1))
  rspamd_config:register_dependency('DEP' .. tostring(i), 'DEP' .. tostring(i - 1))
end