Mercurial Hosting > chat
comparison src/add_post.js.luan @ 40:7ea33179592a
email notification
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 27 Feb 2025 16:44:20 -0700 |
| parents | f4708943f29e |
| children | 9298b04607ae |
comparison
equal
deleted
inserted
replaced
| 39:471b13e6ce2c | 40:7ea33179592a |
|---|---|
| 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 http_push_to_users = Shared.http_push_to_users or error() | 20 local http_push_to_users = Shared.http_push_to_users or error() |
| 21 local Notify = require "site:/lib/Notify.luan" | |
| 21 | 22 |
| 22 | 23 |
| 23 return function() | 24 return function() |
| 24 local user = current_user() or error() | 25 local user = current_user() or error() |
| 25 local chat = Http.request.parameters.chat or error() | 26 local chat = Http.request.parameters.chat or error() |
| 36 } | 37 } |
| 37 post.save() | 38 post.save() |
| 38 chat.updated = now | 39 chat.updated = now |
| 39 chat.save() | 40 chat.save() |
| 40 end ) | 41 end ) |
| 42 Notify.add(chat) | |
| 41 local html = `post_html(post)` | 43 local html = `post_html(post)` |
| 42 local js = "added("..json_string(html)..")" | 44 local js = "added("..json_string(html)..")" |
| 43 chat.http_push(js) | 45 chat.http_push(js) |
| 44 js = "getChats('"..chat.id.."',"..now..")" | 46 js = "getChats('"..chat.id.."',"..now..")" |
| 45 http_push_to_users( chat.user_ids, js ) | 47 http_push_to_users( chat.user_ids, js ) |
