Mercurial Hosting > chat
comparison src/add_post.js.luan @ 15:8b8905f63d80
add get_chats
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 03 Nov 2024 17:36:49 -0700 |
| parents | 9f45d32670ae |
| children | 82b55186a4a0 |
comparison
equal
deleted
inserted
replaced
| 14:0df3a63a895f | 15:8b8905f63d80 |
|---|---|
| 1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
| 2 local error = Luan.error | 2 local error = Luan.error |
| 3 local ipairs = Luan.ipairs or error() | |
| 3 local Time = require "luan:Time.luan" | 4 local Time = require "luan:Time.luan" |
| 4 local time_now = Time.now or error() | 5 local time_now = Time.now or error() |
| 5 local Parsers = require "luan:Parsers.luan" | 6 local Parsers = require "luan:Parsers.luan" |
| 6 local json_string = Parsers.json_string or error() | 7 local json_string = Parsers.json_string or error() |
| 7 local Io = require "luan:Io.luan" | 8 local Io = require "luan:Io.luan" |
| 14 local get_chat_by_id = Chat.get_by_id or error() | 15 local get_chat_by_id = Chat.get_by_id or error() |
| 15 local Post = require "site:/lib/Post.luan" | 16 local Post = require "site:/lib/Post.luan" |
| 16 local new_post = Post.new or error() | 17 local new_post = Post.new or error() |
| 17 local Shared = require "site:/lib/Shared.luan" | 18 local Shared = require "site:/lib/Shared.luan" |
| 18 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" | |
| 21 local base_url = Utils.base_url or error() | |
| 19 | 22 |
| 20 | 23 |
| 21 return function() | 24 return function() |
| 22 local user = current_user() or error() | 25 local user = current_user() or error() |
| 23 local chat = Http.request.parameters.chat or error() | 26 local chat = Http.request.parameters.chat or error() |
| 37 chat.save() | 40 chat.save() |
| 38 end ) | 41 end ) |
| 39 local html = `post_html(post)` | 42 local html = `post_html(post)` |
| 40 local js = "added("..json_string(html)..")" | 43 local js = "added("..json_string(html)..")" |
| 41 chat.http_push(js) | 44 chat.http_push(js) |
| 45 js = "getChats('"..chat.id.."')" | |
| 46 local base = base_url().."/user/" | |
| 47 for _, user_id in ipairs(chat.user_ids) do | |
| 48 local url = base..user_id | |
| 49 Http.push(url,js) | |
| 50 end | |
| 42 end | 51 end |
