4
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local parse = Luan.parse or error()
|
|
4 local Luan_mail = require "luan:mail/Mail.luan"
|
|
5 local Db = require "site:/lib/Db.luan"
|
|
6
|
|
7
|
|
8 local Mail = {}
|
|
9
|
|
10 function Mail.get()
|
|
11 local doc = Db.get_document("type:mail")
|
|
12 return doc and doc.config
|
|
13 end
|
|
14
|
|
15 function Mail.sender()
|
|
16 local text = Mail.get()
|
|
17 if text == nil then
|
|
18 return nil
|
|
19 end
|
|
20 local info = parse(text)
|
|
21 return Luan_mail.sender(info)
|
|
22 end
|
|
23
|
|
24 function Mail.set(text)
|
|
25 if text == nil then
|
|
26 Db.delete("type:mail")
|
|
27 else
|
|
28 do -- test
|
|
29 local info = parse(text)
|
|
30 Luan_mail.sender(info)
|
|
31 end
|
|
32 local doc = Db.get_document("type:mail") or {type="mail"}
|
|
33 doc.config = text
|
|
34 Db.save(doc)
|
|
35 end
|
|
36 end
|
|
37
|
|
38 return Mail
|