Use funcs

This commit is contained in:
Athozus 2023-03-24 21:43:30 +01:00
parent b840f7bce8
commit 615a102d85
No known key found for this signature in database
GPG key ID: B50895022E8484BF

View file

@ -367,20 +367,14 @@ end
function mail.deleteMaillist(ml_id) function mail.deleteMaillist(ml_id)
local maillists = mail.getMaillists() local maillists = mail.getMaillists()
local maillists_players = mail.getPlayersInMaillists()
-- remove players attached to the maillist -- remove players attached to the maillist
for _, player in ipairs(maillists_players) do local players_writing_done = mail.removePlayersFromMaillist(ml_id)
if player.id == ml_id then
table.remove(maillists_players, _)
end
end
-- then remove the maillist itself -- then remove the maillist itself
for _, maillist in ipairs(maillists) do for _, maillist in ipairs(maillists) do
if maillist.id == ml_id then if maillist.id == ml_id then
table.remove(maillists, _) table.remove(maillists, _)
end end
end end
local players_writing_done = mail.write_json_file(mail.maildir .. "/mail.maillists_players.json", maillists_players)
local maillist_writing_done = mail.write_json_file(mail.maildir .. "/mail.maillists.json", maillists) local maillist_writing_done = mail.write_json_file(mail.maildir .. "/mail.maillists.json", maillists)
if players_writing_done and maillist_writing_done then if players_writing_done and maillist_writing_done then
return true return true