Mercurial Hosting > chat
diff src/invite.js.luan @ 60:3521166513b3
finish invite
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 04 Mar 2025 20:31:00 -0700 |
parents | 8270106644db |
children | a47036fd0158 |
line wrap: on
line diff
--- a/src/invite.js.luan Tue Mar 04 08:22:45 2025 -0700 +++ b/src/invite.js.luan Tue Mar 04 20:31:00 2025 -0700 @@ -6,9 +6,16 @@ local Io = require "luan:Io.luan" local User = require "site:/lib/User.luan" local get_user_by_email = User.get_by_email or error() +local get_or_create_user_by_email = User.get_or_create_by_email or error() +local current_user = User.current or error() +local Shared = require "site:/lib/Shared.luan" +local send_mail = Shared.send_mail or error() +local Utils = require "site:/lib/Utils.luan" +local base_url = Utils.base_url or error() return function() + local user = current_user() or error() local email = Http.request.parameters.email or error() Io.stdout = Http.response.text_writer() if get_user_by_email(email) ~= nil then @@ -17,6 +24,23 @@ <% return end + local invitee = get_or_create_user_by_email(email) + local password = invitee.password + local url = base_url().."/do_login.html?user="..invitee.id.."&password="..password.."&with="..user.email + local who = user.name or user.email + send_mail { + To = email + Subject = "Chat with "..who + body = `%> +<%=who%> has invited you to chat on Luan Chat. + +Here is the link to login: + +<%= url %> + +Or login with your email and the password: <%=password%> +<% ` + } %> openInvite(<%=json_string(email)%>); <%