view src/invite.js.luan @ 59:8270106644db

add chat.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Mar 2025 08:22:45 -0700
parents 323ddacc1593
children 3521166513b3
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Parsers = require "luan:Parsers.luan"
local json_string = Parsers.json_string or error()
local Http = require "luan:http/Http.luan"
local Io = require "luan:Io.luan"
local User = require "site:/lib/User.luan"
local get_user_by_email = User.get_by_email or error()


return function()
	local email = Http.request.parameters.email or error()
	Io.stdout = Http.response.text_writer()
	if get_user_by_email(email) ~= nil then
%>
		location = 'chat?with=<%=email%>';
<%
		return
	end
%>
	openInvite(<%=json_string(email)%>);
<%
end