more sanity checks and default values

This commit is contained in:
BuckarooBanzay 2020-09-20 20:18:34 +02:00
parent be51cff470
commit 18592b0a35

11
api.lua
View File

@ -12,6 +12,8 @@ mail.read_later_message = "You can read your messages later by using the /mail c
mail sending function, can be invoked with one object argument (new api) or mail sending function, can be invoked with one object argument (new api) or
all 4 parameters (old compat version) all 4 parameters (old compat version)
see: "Mail format" api.md see: "Mail format" api.md
TODO: refactor this garbage code!
--]] --]]
function mail.send(src, dst, subject, body) function mail.send(src, dst, subject, body)
-- figure out format -- figure out format
@ -33,6 +35,15 @@ function mail.send(src, dst, subject, body)
m.to = m.dst m.to = m.dst
end end
if m.src and not m.from then
-- populate "from" field
m.from = m.src
end
-- sane default values
m.subject = m.subject or ""
m.body = m.body or ""
local cc local cc
local bcc local bcc
local extra local extra