11
|
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()
|
16
|
8 local Shared = require "site:/lib/Shared.luan"
|
|
9 local http_push_to_users = Shared.http_push_to_users or error()
|
17
|
10 local Utils = require "site:/lib/Utils.luan"
|
|
11 local is_in_list = Utils.is_in_list or error()
|
11
|
12
|
|
13
|
|
14 return function()
|
|
15 local chat = Http.request.parameters.chat or error()
|
|
16 chat = get_chat_by_id(chat) or error()
|
17
|
17 local user_ids = chat.user_ids
|
11
|
18 local user = current_user() or error()
|
17
|
19 is_in_list( user.id, user_ids ) or error()
|
11
|
20 chat.delete()
|
16
|
21 local js = "getChats(null)"
|
17
|
22 http_push_to_users( user_ids, js )
|
11
|
23 end
|