Mercurial Hosting > chat
comparison src/save_mute.js.luan @ 104:46418395c860 default tip
add mute chat
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 14 Jul 2025 00:49:11 -0600 |
parents | src/save_post.js.luan@af41be2dcdec |
children |
comparison
equal
deleted
inserted
replaced
103:3ea9783cee39 | 104:46418395c860 |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local Io = require "luan:Io.luan" | |
4 local Http = require "luan:http/Http.luan" | |
5 local Chat = require "site:/lib/Chat.luan" | |
6 local get_chat_by_id = Chat.get_by_id or error() | |
7 local Db = require "site:/lib/Db.luan" | |
8 local run_in_transaction = Db.run_in_transaction or error() | |
9 local Chat = require "site:/lib/Chat.luan" | |
10 local get_chat_by_id = Chat.get_by_id or error() | |
11 local User = require "site:/lib/User.luan" | |
12 local current_user = User.current or error() | |
13 | |
14 | |
15 return function() | |
16 local chat = Http.request.parameters.chat or error() | |
17 local muted = Http.request.parameters.muted or error() | |
18 chat = get_chat_by_id(chat) or error() | |
19 local user_ids = chat.user_ids | |
20 local user = current_user() or error() | |
21 run_in_transaction( function() | |
22 chat = chat.reload() | |
23 chat.mute_ids[user.id] = muted=="true" | |
24 chat.save() | |
25 end ) | |
26 end |