view src/delete_chat.js.luan @ 15:8b8905f63d80

add get_chats
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 Nov 2024 17:36:49 -0700
parents 9f45d32670ae
children 82b55186a4a0
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Http = require "luan:http/Http.luan"
local User = require "site:/lib/User.luan"
local current_user = User.current or error()
local Chat = require "site:/lib/Chat.luan"
local get_chat_by_id = Chat.get_by_id or error()


return function()
	local chat = Http.request.parameters.chat or error()
	chat = get_chat_by_id(chat) or error()
	local user = current_user() or error()
	chat.delete()
	chat.http_push("location = '/chat.html'")
end