Mercurial Hosting > chat
comparison src/invite.js.luan @ 83:a47036fd0158
group chat
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Mar 2025 13:56:59 -0600 |
parents | 3521166513b3 |
children | 7b339b1ccd11 |
comparison
equal
deleted
inserted
replaced
82:0bc5e0d098f7 | 83:a47036fd0158 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local Parsers = require "luan:Parsers.luan" | 3 local Parsers = require "luan:Parsers.luan" |
4 local json_string = Parsers.json_string or error() | 4 local json_string = Parsers.json_string or error() |
5 local Html = require "luan:Html.luan" | |
6 local url_encode = Html.url_encode or error() | |
7 local Io = require "luan:Io.luan" | |
5 local Http = require "luan:http/Http.luan" | 8 local Http = require "luan:http/Http.luan" |
6 local Io = require "luan:Io.luan" | |
7 local User = require "site:/lib/User.luan" | 9 local User = require "site:/lib/User.luan" |
8 local get_user_by_email = User.get_by_email or error() | 10 local get_user_by_email = User.get_by_email or error() |
9 local get_or_create_user_by_email = User.get_or_create_by_email or error() | 11 local get_or_create_user_by_email = User.get_or_create_by_email or error() |
10 local current_user = User.current or error() | 12 local current_user = User.current or error() |
11 local Shared = require "site:/lib/Shared.luan" | 13 local Shared = require "site:/lib/Shared.luan" |
18 local user = current_user() or error() | 20 local user = current_user() or error() |
19 local email = Http.request.parameters.email or error() | 21 local email = Http.request.parameters.email or error() |
20 Io.stdout = Http.response.text_writer() | 22 Io.stdout = Http.response.text_writer() |
21 if get_user_by_email(email) ~= nil then | 23 if get_user_by_email(email) ~= nil then |
22 %> | 24 %> |
23 location = 'chat?with=<%=email%>'; | 25 location = 'chat?with=<%=url_encode(email)%>'; |
24 <% | 26 <% |
25 return | 27 return |
26 end | 28 end |
27 local invitee = get_or_create_user_by_email(email) | 29 local invitee = get_or_create_user_by_email(email) |
28 local password = invitee.password | 30 local password = invitee.password |
29 local url = base_url().."/do_login.html?user="..invitee.id.."&password="..password.."&with="..user.email | 31 local url = base_url().."/do_login.html?user="..invitee.id.."&password="..password.."&with="..url_encode(user.email) |
30 local who = user.name or user.email | 32 local who = user.name or user.email |
31 send_mail { | 33 send_mail { |
32 To = email | 34 To = email |
33 Subject = "Chat with "..who | 35 Subject = "Chat with "..who |
34 body = `%> | 36 body = `%> |