4
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local Parsers = require "luan:Parsers.luan"
|
|
4 local json_string = Parsers.json_string or error()
|
|
5 local Io = require "luan:Io.luan"
|
|
6 local Http = require "luan:http/Http.luan"
|
|
7 local Chat = require "site:/lib/Chat.luan"
|
|
8 local get_chat_by_id = Chat.get_by_id or error()
|
|
9 local User = require "site:/lib/User.luan"
|
|
10 local current_user = User.current or error()
|
|
11 local Db = require "site:/lib/Db.luan"
|
|
12 local run_in_transaction = Db.run_in_transaction or error()
|
|
13
|
|
14
|
|
15 return function()
|
|
16 local chat = Http.request.parameters.chat or error()
|
|
17 local name = Http.request.parameters.name or error()
|
|
18 run_in_transaction( function()
|
|
19 chat = get_chat_by_id(chat) or error()
|
|
20 chat.user_id == current_user().id or error()
|
|
21 chat.name = name
|
|
22 chat.save()
|
|
23 end )
|
|
24 Io.stdout = Http.response.text_writer()
|
|
25 %>
|
29
|
26 setChat(<%= json_string(chat.info()) %>);
|
4
|
27 <%
|
|
28 end
|