check messages for missing time field

This commit is contained in:
BuckarooBanzay 2022-08-06 20:23:35 +02:00
parent bbd6e9123f
commit d1254a7c5b

View File

@ -13,6 +13,13 @@ end
function mail.getMessages(playername)
local messages = mail.read_json_file(mail.getMailFile(playername))
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
table.sort(messages, function(a,b) return a.time > b.time end)
-- show hud notification