Mercurial Hosting > chat
view 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 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() local Db = require "site:/lib/Db.luan" local run_in_transaction = Db.run_in_transaction or error() local Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() local User = require "site:/lib/User.luan" local current_user = User.current or error() return function() local chat = Http.request.parameters.chat or error() local muted = Http.request.parameters.muted or error() chat = get_chat_by_id(chat) or error() local user_ids = chat.user_ids local user = current_user() or error() run_in_transaction( function() chat = chat.reload() chat.mute_ids[user.id] = muted=="true" chat.save() end ) end