Compare commits

...

5 Commits

Author SHA1 Message Date
Athozus
8a992b7a29
Bump version to 1.5.0-dev in about.lua 2024-09-01 16:41:39 +02:00
Maksym H.
1bffd98132 Localize get_translator call 2024-09-01 16:36:55 +02:00
Athozus
59667bd35c
Add 5.9.0 to workflows 2024-08-12 00:33:36 +02:00
Athozus
09b233b039
Update credits and bump to version 1.4.1
Some checks are pending
luacheck / luacheck (push) Waiting to run
test / build (5.8.0) (push) Waiting to run
test / build (latest) (push) Waiting to run
test / build (5.0.1) (push) Waiting to run
test / build (5.1.1) (push) Waiting to run
test / build (5.2.0) (push) Waiting to run
test / build (5.3.0) (push) Waiting to run
test / build (5.4.1) (push) Waiting to run
test / build (5.5.1) (push) Waiting to run
test / build (5.6.1) (push) Waiting to run
test / build (5.7.0) (push) Waiting to run
2024-08-09 00:35:42 +02:00
Athozus
b9982f11e6
Add support for a get_keys() equivalent for lower than 5.7 Minetest versions (#153)
* Add support for a get_keys() equivalent for lower than 5.7 Minetest versions

* Do not call the function itself to check if it exists

Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>

* Do not call the function itself to check if it exists (2)

Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>

* Fix an occurrence of get_keys() in is_uuid_existing()

---------

Co-authored-by: luk3yx <luk3yx@users.noreply.github.com>
2024-08-09 00:31:28 +02:00
24 changed files with 104 additions and 64 deletions

View File

@ -9,7 +9,7 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
ENGINE_VERSION: [5.0.1, 5.1.1, 5.2.0, 5.3.0, 5.4.1, 5.5.1, 5.6.1, 5.7.0, 5.8.0, latest]
ENGINE_VERSION: [5.0.1, 5.1.1, 5.2.0, 5.3.0, 5.4.1, 5.5.1, 5.6.1, 5.7.0, 5.8.0, 5.9.0, latest]
steps:
- uses: actions/checkout@v4

View File

@ -76,7 +76,7 @@ See the "LICENSE" file
* fluxionary (Minor fixups)
* Toby1710 (UX fixes)
* Peter Nerlich (CC, BCC)
* Emojigit (Traditional Chinese translation)
* Emojigit (Performance, Traditional Chinese translation)
* Niklp09 (German translation)
* Dennis Jenkins (UX fixes)
* Thomas Rudin (Maintenance)

View File

@ -1,7 +1,7 @@
-- see: mail.md
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local f = string.format

View File

@ -5,6 +5,9 @@ mail = {
-- mod storage
storage = minetest.get_mod_storage(),
-- translation
S = minetest.get_translator(minetest.get_current_modname()),
-- ui theme prepend
theme = "",

View File

@ -91,17 +91,29 @@ local function search_box(playername, box, uuid)
return false
end
local function search_boxes(playername, boxes, uuid)
local result
for _, b in ipairs(boxes) do
result = search_box(playername, b, uuid)
if result then return result end
end
end
local function is_uuid_existing(uuid)
for _, k in ipairs(mail.storage:get_keys()) do
if string.sub(k,1,5) == "mail/" then
local p = string.sub(k, 6)
local result
local boxes = {"inbox", "outbox", "drafts", "trash"}
for _, b in ipairs(boxes) do
result = search_box(p, b, uuid)
local boxes = {"inbox", "outbox", "drafts", "trash"}
if mail.storage.get_keys then
for _, k in ipairs(mail.storage:get_keys()) do
if string.sub(k,1,5) == "mail/" then
local p = string.sub(k, 6)
local result = search_boxes(p, boxes, uuid)
if result then return result end
end
end
else
for p, _ in minetest.get_auth_handler().iterate() do
local result = search_boxes(p, boxes, uuid)
if result then return result end
end
end
return false
end
@ -116,55 +128,78 @@ local function are_message_sames(a, b)
and a.body == b.body
end
local function fix_duplicate_uuids(playername, box)
local function replace_other_player_message_uuid(p, m, uuid, new_uuid)
local er = mail.get_storage_entry(p)
for _, r in ipairs(er.inbox) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
for _, r in ipairs(er.outbox) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
for _, r in ipairs(er.drafts) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
for _, r in ipairs(er.trash) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
mail.set_storage_entry(p, er)
end
local function fix_box_duplicate_uuids(playername, box)
local e = mail.get_storage_entry(playername)
for _, m in ipairs(e[box]) do
local uuid = m.id
local exists = is_uuid_existing(uuid)
if exists and not are_message_sames(exists, m) then
local new_uuid = mail.new_uuid() -- generates a new uuid to replace doublons
for _, k in ipairs(mail.storage:get_keys()) do
if string.sub(k,1,5) == "mail/" then
local p = string.sub(k, 6)
local er = mail.get_storage_entry(p)
for _, r in ipairs(er.inbox) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
if mail.storage.get_keys then
for _, k in ipairs(mail.storage:get_keys()) do
if string.sub(k,1,5) == "mail/" then
local p = string.sub(k, 6)
replace_other_player_message_uuid(p, m, uuid, new_uuid)
end
for _, r in ipairs(er.outbox) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
for _, r in ipairs(er.drafts) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
for _, r in ipairs(er.trash) do
if r.id == uuid and not are_message_sames(m, r) then
r.id = new_uuid
end
end
mail.set_storage_entry(p, er)
end
else
for p, _ in minetest.get_auth_handler().iterate() do
replace_other_player_message_uuid(p, m, uuid, new_uuid)
end
end
end
end
end
local function fix_player_duplicate_uuids(playername)
fix_box_duplicate_uuids(playername, "inbox")
fix_box_duplicate_uuids(playername, "outbox")
fix_box_duplicate_uuids(playername, "drafts")
fix_box_duplicate_uuids(playername, "trash")
end
-- repair database for uuid doublons
local function repair_storage()
-- iterate through players
for _, k in ipairs(mail.storage:get_keys()) do
if string.sub(k,1,5) == "mail/" then
local p = string.sub(k, 6)
fix_duplicate_uuids(p, "inbox")
fix_duplicate_uuids(p, "outbox")
fix_duplicate_uuids(p, "drafts")
fix_duplicate_uuids(p, "trash")
-- get_keys() was introduced in 5.7
if mail.storage.get_keys then
for _, k in ipairs(mail.storage:get_keys()) do
if string.sub(k,1,5) == "mail/" then
local p = string.sub(k, 6)
fix_player_duplicate_uuids(p)
end
end
else
minetest.after(0, function()
for p, _ in minetest.get_auth_handler().iterate() do
fix_player_duplicate_uuids(p)
end
end)
end
end

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
minetest.register_on_joinplayer(function(player)
minetest.after(2, function(name)

View File

@ -1,4 +1,6 @@
local S = minetest.get_translator("mail")
-- translation
local S = mail.S
local has_canonical_name = minetest.get_modpath("canonical_name")
mail.register_on_player_receive(function(name, msg)

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:about"
@ -19,7 +19,7 @@ local contributors = {
{ name = "BuckarooBanzay", groups = {"c"} },
{ name = "Chache", groups = {"i"} },
{ name = "Dennis Jenkins", groups = {"c"} },
{ name = "Emojigit", groups = {"i"} },
{ name = "Emojigit", groups = {"c", "i"} },
{ name = "Eredin", groups = {"i"} },
{ name = "fluxionary", groups = {"c"} },
{ name = "imre84", groups = {"c"} },
@ -55,7 +55,7 @@ function mail.show_about(name)
label[0.2,0;Mail]
label[0.2,0.5;]] .. S("Provided by mt-mods") .. [[]
label[0.2,0.9;]] .. S("Version: @1", "1.4.1-dev") .. [[]
label[0.2,0.9;]] .. S("Version: @1", "1.5.0-dev") .. [[]
box[0,1.5;3,0.45;]] .. mail.get_color("highlighted") .. [[]
label[0.2,1.5;]] .. S("Licenses") .. [[]

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:compose"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:contacts"

View File

@ -1,6 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
function mail.show_drafts(name)
local trash_tab = ""

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:editcontact"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:editmaillist"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name])

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:maillists"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:message"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name])

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:selectcontact"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local FORMNAME = "mail:settings"

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
local trash_formspec = "size[8.5,11;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] ..

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
function mail.compile_contact_list(name, selected, playernames)
-- TODO: refactor this - not just compiles *a* list, but *the* list for the contacts screen (too inflexible)

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator("mail")
-- translation
local S = mail.S
local function recursive_expand_recipient_names(sender, list, is_toplevel, recipients, undeliverable)
for _, name in ipairs(list) do

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
mail.settings = {
chat_notifications = {

View File

@ -1,5 +1,5 @@
-- translation
local S = minetest.get_translator("mail")
local S = mail.S
function mail.time_ago(t)
local elapsed = os.time() - t