Debian Codegraph @

test/functional/lua/params.lua

raw
1 rspamd_config.TEST_RCPT = {
2 callback = function(task)
3 local l = {}
4 local rcpts = task:get_recipients(1)
5 if not rcpts then return end
6 for _, r in ipairs(rcpts) do
7 table.insert(l, r['addr'])
8 end
9 table.sort(l)
10 local t = table.concat(l, ",")
11 return true, t
12 end
13 }
14
15 rspamd_config.TEST_HELO = {
16 callback = function(task)
17 local helo = task:get_helo()
18 if not helo then return end
19 return true, helo
20 end
21 }
22
23 rspamd_config.TEST_HOSTNAME = {
24 callback = function(task)
25 local h = task:get_hostname()
26 if not h then return end
27 return true, h
28 end
29 }
30
31 rspamd_config.TEST_SMTP_FROM = {
32 callback = function(task)
33 local f = task:get_from('smtp')
34 if not (f and f[1] and f[1].addr) then return end
35 return true, f[1].addr
36 end
37 }
38
39 rspamd_config.TEST_MTA_TAG = {
40 callback = function(task)
41 local h = task:get_request_header('MTA-Tag')
42 if not h then return end
43 return true, tostring(h)
44 end
45 }
46
47 rspamd_config.TEST_USER = {
48 callback = function(task)
49 local u = task:get_user()
50 if not u then return end
51 return true, u
52 end
53 }
54
55 rspamd_config.TEST_QUEUEID = {
56 callback = function(task)
57 local q = task:get_queue_id()
58 if not q then return end
59 return true, q
60 end
61 }
62
63 rspamd_config.TEST_IPADDR = {
64 callback = function(task)
65 local i = task:get_from_ip()
66 if not (i and i:is_valid()) then return end
67 return true, tostring(i)
68 end
69 }
70
71 rspamd_config.FORCE_DEFER = {
72 callback = function(task)
73 local f = task:get_from('smtp')
74 if not (f and f[1] and f[1].addr) then return end
75 if f[1].addr == "[email protected]" then
76 task:set_pre_result('soft reject', 'Try much later')
77 return true
78 end
79 end
80 }