mirror of
https://github.com/mt-mods/mail.git
synced 2025-05-20 18:13:21 -04:00
fix some of the issues from PR #4 (still does not work but the initial work should be done)
This commit is contained in:
parent
f5f21feb49
commit
6bf2e5fc41
3 changed files with 21 additions and 38 deletions
30
api.lua
30
api.lua
|
@ -29,36 +29,20 @@ function mail.send(src, dst, subject, body)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log mail send action
|
-- log mail send action
|
||||||
if m.cc or m.bcc then
|
minetest.log("action", "[mail] '" .. m.from .. "' sends mail to '" .. m.to .. "', " ..
|
||||||
if m.cc then
|
"cc: ''" .. m.cc .. "', " ..
|
||||||
cc = "CC: " .. m.cc
|
"bcc: ''" .. m.bcc .. "', " ..
|
||||||
if m.bcc then
|
"with subject '" .. m.subject .. "' and body: '" .. m.body .. "'")
|
||||||
cc = cc .. " - "
|
|
||||||
end
|
|
||||||
else
|
|
||||||
cc = ""
|
|
||||||
end
|
|
||||||
if m.bcc then
|
|
||||||
bcc = "BCC: " .. m.bcc
|
|
||||||
else
|
|
||||||
bcc = ""
|
|
||||||
end
|
|
||||||
extra = "(" .. cc .. bcc .. ") "
|
|
||||||
else
|
|
||||||
extra = ""
|
|
||||||
end
|
|
||||||
minetest.log("action", "[mail] '" .. m.from .. "' sends mail to '" .. m.to ..
|
|
||||||
extra .. "' with subject '" .. m.subject .. "' and body: '" .. m.body .. "'")
|
|
||||||
|
|
||||||
|
|
||||||
-- normalize to, cc and bcc while compiling a list of all recipients
|
-- normalize to, cc and bcc while compiling a list of all recipients
|
||||||
local recipients = {}
|
local recipients = {}
|
||||||
m.to = normalize_players_and_add_recipients(m.to, recipients)
|
m.to = mail.normalize_players_and_add_recipients(m.to, recipients)
|
||||||
if m.cc then
|
if m.cc then
|
||||||
m.cc = normalize_players_and_add_recipients(m.cc, recipients)
|
m.cc = mail.normalize_players_and_add_recipients(m.cc, recipients)
|
||||||
end
|
end
|
||||||
if m.bcc then
|
if m.bcc then
|
||||||
m.bcc = normalize_players_and_add_recipients(m.bcc, recipients)
|
m.bcc = mail.normalize_players_and_add_recipients(m.bcc, recipients)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- form the actual mail
|
-- form the actual mail
|
||||||
|
|
27
gui.lua
27
gui.lua
|
@ -99,23 +99,22 @@ end
|
||||||
|
|
||||||
function mail.show_compose(name, defaultto, defaultsubj, defaultbody, defaultcc, defaultbcc)
|
function mail.show_compose(name, defaultto, defaultsubj, defaultbody, defaultcc, defaultbcc)
|
||||||
local formspec = [[
|
local formspec = [[
|
||||||
size[8,7.2]
|
size[8,9.2]
|
||||||
field[0.25,0.5;4,1;to;To:;%s]
|
field[0.25,0.5;8,1;to;To:;%s]
|
||||||
field[0.25,0.5;4,1;to;CC:;%s]
|
field[0.25,1.5;8,1;cc;CC:;%s]
|
||||||
field[0.25,0.5;4,1;to;BCC:;%s]
|
field[0.25,2.5;8,1;bcc;BCC:;%s]
|
||||||
field[0.25,1.7;8,1;subject;Subject:;%s]
|
field[0.25,3.7;8,1;subject;Subject:;%s]
|
||||||
textarea[0.25,2.4;8,5;body;;%s]
|
textarea[0.25,4.4;8,5;body;;%s]
|
||||||
button[0.5,6.7;3,1;cancel;Cancel]
|
button[0.5,8.7;3,1;cancel;Cancel]
|
||||||
button[7,0;1,0.5;cancel;X]
|
button[4.5,8.7;3,1;send;Send]
|
||||||
button[4.5,6.7;3,1;send;Send]
|
|
||||||
]] .. theme
|
]] .. theme
|
||||||
|
|
||||||
formspec = string.format(formspec,
|
formspec = string.format(formspec,
|
||||||
minetest.formspec_escape(defaultto),
|
minetest.formspec_escape(defaultto),
|
||||||
|
minetest.formspec_escape(defaultcc) or "",
|
||||||
|
minetest.formspec_escape(defaultbcc) or "",
|
||||||
minetest.formspec_escape(defaultsubj),
|
minetest.formspec_escape(defaultsubj),
|
||||||
minetest.formspec_escape(defaultbody),
|
minetest.formspec_escape(defaultbody))
|
||||||
minetest.formspec_escape(defaultcc),
|
|
||||||
minetest.formspec_escape(defaultbcc))
|
|
||||||
|
|
||||||
minetest.show_formspec(name, "mail:compose", formspec)
|
minetest.show_formspec(name, "mail:compose", formspec)
|
||||||
end
|
end
|
||||||
|
@ -221,8 +220,8 @@ function mail.handle_receivefields(player, formname, fields)
|
||||||
mail.send({
|
mail.send({
|
||||||
from = player:get_player_name(),
|
from = player:get_player_name(),
|
||||||
to = fields.to,
|
to = fields.to,
|
||||||
cc = "",
|
cc = fields.cc,
|
||||||
bcc = ""
|
bcc = fields.bcc,
|
||||||
subject = fields.subject,
|
subject = fields.subject,
|
||||||
body = fields.body
|
body = fields.body
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
return the field normalized (comma separated, single space)
|
return the field normalized (comma separated, single space)
|
||||||
and add individual player names to recipient list
|
and add individual player names to recipient list
|
||||||
--]]
|
--]]
|
||||||
function normalize_players_and_add_recipients(field, recipients)
|
function mail.normalize_players_and_add_recipients(field, recipients)
|
||||||
local separator = ", "
|
local separator = ", "
|
||||||
local pattern = "([^" .. separator .. "]+)"
|
local pattern = "([^" .. separator .. "]+)"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue