Mercurial Hosting > lang
comparison src/chat.json.luan @ 49:97b0d206cacd
add chat.json
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 15 Aug 2025 08:43:24 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:a119fc092f42 | 49:97b0d206cacd |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local Http = require "luan:http/Http.luan" | |
4 local User = require "site:/lib/User.luan" | |
5 local current_user = User.current or error() | |
6 local Chat = require "site:/lib/Chat.luan" | |
7 local get_chat_by_id = Chat.get_by_id or error() | |
8 | |
9 | |
10 return function() | |
11 local chat_id = Http.request.parameters.chat or error() | |
12 local chat = get_chat_by_id(chat_id) or error() | |
13 local user = current_user() | |
14 local is_owner = user ~= nil and user.id == chat.user_id | |
15 is_owner or not chat.is_private or error "private" | |
16 Http.response.text_writer().write(chat.ai_thread) | |
17 end |