Skip to content

Commit

Permalink
Use interleaved style (#124)
Browse files Browse the repository at this point in the history
* Generate interleaved style when replying/forwarding a message (#120)

* Simplify interleaving function

Co-authored-by: SX <[email protected]>

---------

Co-authored-by: SX <[email protected]>
  • Loading branch information
Athozus and S-S-X authored Dec 8, 2023
1 parent 3bad371 commit 77de24e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ui/message.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ local S = minetest.get_translator("mail")

local FORMNAME = "mail:message"

local function interleaveMsg(body)
return "> " .. (body or ""):gsub("\n", "\n> ")
end


function mail.show_message(name, id)
local message = mail.get_message(name, id)
if not message then
Expand Down Expand Up @@ -65,8 +70,7 @@ function mail.reply(name, message)
minetest.log("error", "[mail] current mail-context: " .. dump(mail.selected_idxs))
return
end
local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body
mail.show_compose(name, message.from, "Re: "..message.subject, replyfooter)
mail.show_compose(name, message.from, "Re: "..message.subject, interleaveMsg(message.body))
end

function mail.replyall(name, message)
Expand All @@ -77,8 +81,6 @@ function mail.replyall(name, message)
return
end

local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body

-- new recipients are the sender plus the original recipients, minus ourselves
local recipients = message.to or ""
if message.from ~= nil then
Expand All @@ -103,12 +105,11 @@ function mail.replyall(name, message)
end
cc = mail.concat_player_list(cc)

mail.show_compose(name, recipients, "Re: "..message.subject, replyfooter, cc)
mail.show_compose(name, recipients, "Re: "..message.subject, interleaveMsg(message.body), cc)
end

function mail.forward(name, message)
local fwfooter = "Type your message here.\n\n--Original message follows--\n" .. (message.body or "")
mail.show_compose(name, "", "Fw: " .. (message.subject or ""), fwfooter)
mail.show_compose(name, "", "Fw: " .. (message.subject or ""), interleaveMsg(message.body))
end

minetest.register_on_player_receive_fields(function(player, formname, fields)
Expand Down

0 comments on commit 77de24e

Please sign in to comment.