Mercurial Hosting > chat
comparison src/delete_chat.js.luan @ 17:7230c821c368
push fixes
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 04 Nov 2024 14:44:35 -0700 |
| parents | 82b55186a4a0 |
| children | 323ddacc1593 |
comparison
equal
deleted
inserted
replaced
| 16:82b55186a4a0 | 17:7230c821c368 |
|---|---|
| 5 local current_user = User.current or error() | 5 local current_user = User.current or error() |
| 6 local Chat = require "site:/lib/Chat.luan" | 6 local Chat = require "site:/lib/Chat.luan" |
| 7 local get_chat_by_id = Chat.get_by_id or error() | 7 local get_chat_by_id = Chat.get_by_id or error() |
| 8 local Shared = require "site:/lib/Shared.luan" | 8 local Shared = require "site:/lib/Shared.luan" |
| 9 local http_push_to_users = Shared.http_push_to_users or error() | 9 local http_push_to_users = Shared.http_push_to_users or error() |
| 10 local Utils = require "site:/lib/Utils.luan" | |
| 11 local is_in_list = Utils.is_in_list or error() | |
| 10 | 12 |
| 11 | 13 |
| 12 return function() | 14 return function() |
| 13 local chat = Http.request.parameters.chat or error() | 15 local chat = Http.request.parameters.chat or error() |
| 14 chat = get_chat_by_id(chat) or error() | 16 chat = get_chat_by_id(chat) or error() |
| 17 local user_ids = chat.user_ids | |
| 15 local user = current_user() or error() | 18 local user = current_user() or error() |
| 19 is_in_list( user.id, user_ids ) or error() | |
| 16 chat.delete() | 20 chat.delete() |
| 17 local js = "getChats(null)" | 21 local js = "getChats(null)" |
| 18 http_push_to_users( chat.user_ids, js ) | 22 http_push_to_users( user_ids, js ) |
| 19 end | 23 end |
