annotate src/invite.js.luan @ 56:323ddacc1593

start invite
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Mar 2025 07:00:42 -0700
parents
children 8270106644db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Parsers = require "luan:Parsers.luan"
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local json_string = Parsers.json_string or error()
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Http = require "luan:http/Http.luan"
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Io = require "luan:Io.luan"
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local User = require "site:/lib/User.luan"
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local get_user_by_email = User.get_by_email or error()
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 return function()
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local email = Http.request.parameters.email or error()
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 Io.stdout = Http.response.text_writer()
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 if get_user_by_email(email) ~= nil then
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 %>
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 location = '?with=<%=email%>';
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 <%
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 return
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 end
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 %>
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 openInvite(<%=json_string(email)%>);
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <%
323ddacc1593 start invite
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 end