Mercurial Hosting > chat
comparison src/add_post.js.luan @ 16:82b55186a4a0
fix delete_chat
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 03 Nov 2024 21:22:06 -0700 |
| parents | 8b8905f63d80 |
| children | f4708943f29e |
comparison
equal
deleted
inserted
replaced
| 15:8b8905f63d80 | 16:82b55186a4a0 |
|---|---|
| 15 local get_chat_by_id = Chat.get_by_id or error() | 15 local get_chat_by_id = Chat.get_by_id or error() |
| 16 local Post = require "site:/lib/Post.luan" | 16 local Post = require "site:/lib/Post.luan" |
| 17 local new_post = Post.new or error() | 17 local new_post = Post.new or error() |
| 18 local Shared = require "site:/lib/Shared.luan" | 18 local Shared = require "site:/lib/Shared.luan" |
| 19 local post_html = Shared.post_html or error() | 19 local post_html = Shared.post_html or error() |
| 20 local Utils = require "site:/lib/Utils.luan" | 20 local http_push_to_users = Shared.http_push_to_users or error() |
| 21 local base_url = Utils.base_url or error() | |
| 22 | 21 |
| 23 | 22 |
| 24 return function() | 23 return function() |
| 25 local user = current_user() or error() | 24 local user = current_user() or error() |
| 26 local chat = Http.request.parameters.chat or error() | 25 local chat = Http.request.parameters.chat or error() |
| 41 end ) | 40 end ) |
| 42 local html = `post_html(post)` | 41 local html = `post_html(post)` |
| 43 local js = "added("..json_string(html)..")" | 42 local js = "added("..json_string(html)..")" |
| 44 chat.http_push(js) | 43 chat.http_push(js) |
| 45 js = "getChats('"..chat.id.."')" | 44 js = "getChats('"..chat.id.."')" |
| 46 local base = base_url().."/user/" | 45 http_push_to_users( chat.user_ids, js ) |
| 47 for _, user_id in ipairs(chat.user_ids) do | |
| 48 local url = base..user_id | |
| 49 Http.push(url,js) | |
| 50 end | |
| 51 end | 46 end |
