Add insertion of messages into global storage mail.messages.json

This commit is contained in:
Athozus 2023-03-01 11:36:13 +01:00
parent 17b5f94fed
commit 0d69f0242b
No known key found for this signature in database
GPG key ID: B50895022E8484BF
4 changed files with 36 additions and 15 deletions

10
api.lua
View file

@ -93,13 +93,9 @@ function mail.send(...)
body = m.body,
time = os.time(),
}
-- send the mail to all recipients
for recipient in pairs(recipients) do
local messages = mail.getMessages(recipient)
table.insert(messages, 1, msg)
mail.setMessages(recipient, messages)
end
-- insert in global storage
mail.addMessage(msg)
-- notify recipients that happen to be online
local mail_alert = f(mail.receive_mail_message, m.from, m.subject)