forked from mailru/tntlua
-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_mailer.lua
66 lines (48 loc) · 1.32 KB
/
list_mailer.lua
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
-- space 0:
-- tuple : (listid, email)
-- space 1:
-- tuple : (listid, subj_prefix)
-- function returns list of mailer
function list_mailer_get(listid)
listid = box.unpack('i', listid)
local result = { }
local tuples = { box.select(0, 0, listid) }
if tuples == nil then
return
else
for _, tuple in pairs(tuples) do
table.insert(result, tuple[1])
end
return unpack(result)
end
end
function list_mailer_get_ext(listid)
listid = box.unpack('i', listid)
local properties = box.select(1, 0, listid)
local subj_prefix = ""
if properties ~= nil then subj_prefix = properties[1] end
local result = { subj_prefix }
local tuples = { box.select(0, 0, listid) }
if tuples == nil then return end
for _, tuple in pairs(tuples) do
table.insert(result, tuple[1])
end
return unpack(result)
end
function list_mailer_get_ext2(listid)
listid = box.unpack('i', listid)
local properties = box.select(1, 0, listid)
local subj_prefix = ""
local flags = 0
if properties ~= nil then
subj_prefix = properties[1]
if #properties > 2 then flags = box.unpack('i', properties[2]) end
end
local result = { subj_prefix, flags }
local tuples = { box.select(0, 0, listid) }
if tuples == nil then return end
for _, tuple in pairs(tuples) do
table.insert(result, tuple[1])
end
return unpack(result)
end