diff --git a/.luacheckrc b/.luacheckrc index 9bd0493..4e36bc3 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -18,5 +18,5 @@ read_globals = { "unified_inventory", "default", -- optional mods - "xban", "QoS", "mtt" + "mtt" } diff --git a/LICENSE b/LICENSE index caa7028..88baf62 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,6 @@ The file textures/mail_button.png was created by bas080 and is licensed under the WTFPL. -Webmail component: -WTFPL - All other files: Copyright (c) 2016 Carter Kolwey ("Cheapie Systems") diff --git a/README.md b/README.md index dce43c6..4823a14 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Install it like any other mod: copy the directory `mail_mod` to your "worldmods" ## Webmail -See: https://github.com/minetest-mail/mail +To provide a web-based interface to receive/send mails you can use the [mtui](https://github.com/minetest-go/mtui) project # Commands/Howto diff --git a/attachment.lua b/attachment.lua deleted file mode 100644 index efb76d9..0000000 --- a/attachment.lua +++ /dev/null @@ -1,27 +0,0 @@ - -local invmap = {} - - -mail.getAttachmentInventory = function(playername) - return invmap[playername] -end - -mail.getAttachmentInventoryName = function(playername) - return "mail:" .. playername -end - - -minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() - local inv = minetest.create_detached_inventory(mail.getAttachmentInventoryName(name), {}) - - invmap[name] = inv -end) - -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - invmap[name] = nil - if minetest.remove_detached_inventory then - minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name)) - end -end) diff --git a/init.lua b/init.lua index 1b67e7e..c607b1b 100644 --- a/init.lua +++ b/init.lua @@ -1,28 +1,10 @@ mail = { - - -- mark webmail fork for other mods - fork = "webmail", - -- api version apiversion = 1.1, -- mail directory maildir = minetest.get_worldpath().."/mails", - contactsdir = minetest.get_worldpath().."/mails/contacts", - - -- allow item/node attachments - allow_attachments = minetest.settings:get("mail.allow_attachments") == "true", - - webmail = { - -- disallow banned players in the webmail interface - disallow_banned_players = minetest.settings:get("webmail.disallow_banned_players") == "true", - - -- url and key to the webmail server - url = minetest.settings:get("webmail.url"), - key = minetest.settings:get("webmail.key") - }, - - tan = {} + contactsdir = minetest.get_worldpath().."/mails/contacts" } @@ -30,38 +12,12 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) dofile(MP .. "/util/normalize.lua") dofile(MP .. "/chatcommands.lua") dofile(MP .. "/migrate.lua") -dofile(MP .. "/attachment.lua") dofile(MP .. "/hud.lua") dofile(MP .. "/storage.lua") dofile(MP .. "/api.lua") dofile(MP .. "/gui.lua") dofile(MP .. "/onjoin.lua") --- optional webmail stuff below -local http = QoS and QoS(minetest.request_http_api(), 2) or minetest.request_http_api() - -if http then - local webmail_url = mail.webmail.url - local webmail_key = mail.webmail.key - - if not webmail_url then error("webmail.url is not defined") end - if not webmail_key then error("webmail.key is not defined") end - - print("[mail] loading webmail-component with endpoint: " .. webmail_url) - - mail.handlers = {} - dofile(MP .. "/webmail/tan.lua") - dofile(MP .. "/webmail/webmail.lua") - dofile(MP .. "/webmail/hook.lua") - dofile(MP .. "/webmail/handler_auth.lua") - dofile(MP .. "/webmail/handler_send.lua") - dofile(MP .. "/webmail/handler_messages.lua") - dofile(MP .. "/webmail/handler_delete.lua") - dofile(MP .. "/webmail/handler_mark_read.lua") - dofile(MP .. "/webmail/handler_mark_unread.lua") - mail.webmail_init(http, webmail_url, webmail_key) -end - -- migrate storage mail.migrate() diff --git a/mod.conf b/mod.conf index e38d49b..64f3889 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = mail description = ingame mail-system -optional_depends = unified_inventory,default,xban2,qos,mtt +optional_depends = unified_inventory,default,mtt diff --git a/webmail/handler_auth.lua b/webmail/handler_auth.lua deleted file mode 100644 index dcc8417..0000000 --- a/webmail/handler_auth.lua +++ /dev/null @@ -1,45 +0,0 @@ -local has_xban2_mod = minetest.get_modpath("xban2") - --- auth request from webmail -function mail.handlers.auth(auth) - local handler = minetest.get_auth_handler() - minetest.log("action", "[webmail] auth: " .. auth.name) - - local success = false - local banned = false - local message = "" - - if mail.webmail.disallow_banned_players and has_xban2_mod then - -- check xban db - local xbanentry = xban.find_entry(auth.name) - if xbanentry and xbanentry.banned then - banned = true - message = "Banned!" - end - end - - if not banned then - -- check tan - local tan = mail.tan[auth.name] - if tan ~= nil then - success = tan == auth.password - end - - -- check auth - if not success then - local entry = handler.get_auth(auth.name) - if entry and minetest.check_password_entry(auth.name, entry.password, auth.password) then - success = true - end - end - end - - mail.channel.send({ - type = "auth", - data = { - name = auth.name, - success = success, - message = message - } - }) -end diff --git a/webmail/handler_delete.lua b/webmail/handler_delete.lua deleted file mode 100644 index 2809bed..0000000 --- a/webmail/handler_delete.lua +++ /dev/null @@ -1,8 +0,0 @@ --- remove mail -function mail.handlers.delete(playername, index) - local messages = mail.getMessages(playername) - if messages[index] then - table.remove(messages, index) - end - mail.setMessages(playername, messages) -end diff --git a/webmail/handler_mark_read.lua b/webmail/handler_mark_read.lua deleted file mode 100644 index a1ddf0f..0000000 --- a/webmail/handler_mark_read.lua +++ /dev/null @@ -1,9 +0,0 @@ - --- mark mail as read -function mail.handlers.mark_read(playername, index) - local messages = mail.getMessages(playername) - if messages[index] then - messages[index].unread = false - end - mail.setMessages(playername, messages) -end diff --git a/webmail/handler_mark_unread.lua b/webmail/handler_mark_unread.lua deleted file mode 100644 index 75331ce..0000000 --- a/webmail/handler_mark_unread.lua +++ /dev/null @@ -1,9 +0,0 @@ - --- mark mail as unread -function mail.handlers.mark_unread(playername, index) - local messages = mail.getMessages(playername) - if messages[index] then - messages[index].unread = true - end - mail.setMessages(playername, messages) -end diff --git a/webmail/handler_messages.lua b/webmail/handler_messages.lua deleted file mode 100644 index c1693a4..0000000 --- a/webmail/handler_messages.lua +++ /dev/null @@ -1,9 +0,0 @@ --- get player messages request from webmail -function mail.handlers.messages(playername) - local messages = mail.getMessages(playername) - mail.channel.send({ - type = "player-messages", - playername = playername, - data = messages - }) -end diff --git a/webmail/handler_send.lua b/webmail/handler_send.lua deleted file mode 100644 index 6301611..0000000 --- a/webmail/handler_send.lua +++ /dev/null @@ -1,7 +0,0 @@ - --- send request from webmail -function mail.handlers.send(sendmail) - -- send mail from webclient - minetest.log("action", "[webmail] sending mail from webclient: " .. sendmail.from .. " -> " .. sendmail.to) - mail.send(sendmail) -end diff --git a/webmail/hook.lua b/webmail/hook.lua deleted file mode 100644 index afe87a8..0000000 --- a/webmail/hook.lua +++ /dev/null @@ -1,8 +0,0 @@ -function mail.webmail_send_hook(m) - mail.channel.send({ - type = "new-message", - data = m - }) -end - -mail.register_on_receive(mail.webmail_send_hook) diff --git a/webmail/tan.lua b/webmail/tan.lua deleted file mode 100644 index 95d116c..0000000 --- a/webmail/tan.lua +++ /dev/null @@ -1,16 +0,0 @@ - - -minetest.register_chatcommand("webmail_tan", { - description = "generates a tan (temporary access number) for the webmail access", - func = function(name) - local tan = "" .. math.random(1000, 9999) - mail.tan[name] = tan - - return true, "Your tan is " .. tan .. ", it will expire upon leaving the game" - end -}) - -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - mail.tan[name] = nil -end) diff --git a/webmail/webmail.lua b/webmail/webmail.lua deleted file mode 100644 index ed5a213..0000000 --- a/webmail/webmail.lua +++ /dev/null @@ -1,31 +0,0 @@ -local MP = minetest.get_modpath(minetest.get_current_modname()) -local Channel = dofile(MP .. "/util/channel.lua") - - -function mail.webmail_init(http, url, key) - mail.channel = Channel(http, url .. "/api/minetest/channel", { - extra_headers = { "webmailkey: " .. key } - }) - - mail.channel.receive(function(data) - if data.type == "auth" then - mail.handlers.auth(data.data) - - elseif data.type == "send" then - mail.handlers.send(data.data) -- { src, dst, subject, body } - - elseif data.type == "delete-mail" then - mail.handlers.delete(data.playername, data.index) -- index 1-based - - elseif data.type == "mark-mail-read" then - mail.handlers.mark_read(data.playername, data.index) -- index 1-based - - elseif data.type == "mark-mail-unread" then - mail.handlers.mark_unread(data.playername, data.index) -- index 1-based - - elseif data.type == "player-messages" then - mail.handlers.messages(data.data) - - end - end) -end