mirror of
https://github.com/mt-mods/mail.git
synced 2025-03-15 14:11:26 +00:00
check messages for missing time field
This commit is contained in:
parent
bbd6e9123f
commit
d1254a7c5b
1 changed files with 7 additions and 0 deletions
|
@ -13,6 +13,13 @@ end
|
||||||
function mail.getMessages(playername)
|
function mail.getMessages(playername)
|
||||||
local messages = mail.read_json_file(mail.getMailFile(playername))
|
local messages = mail.read_json_file(mail.getMailFile(playername))
|
||||||
if messages then
|
if messages then
|
||||||
|
for _, msg in ipairs(messages) do
|
||||||
|
if not msg.time then
|
||||||
|
-- add missing time field if not available (happens with old data)
|
||||||
|
msg.time = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- sort by received date descending
|
-- sort by received date descending
|
||||||
table.sort(messages, function(a,b) return a.time > b.time end)
|
table.sort(messages, function(a,b) return a.time > b.time end)
|
||||||
-- show hud notification
|
-- show hud notification
|
||||||
|
|
Loading…
Add table
Reference in a new issue