generated from lucien/api-template
Compare commits
2 commits
d38c963bab
...
8f77a271e1
Author | SHA1 | Date | |
---|---|---|---|
8f77a271e1 | |||
92ea1d6b21 |
2 changed files with 1 additions and 9 deletions
|
@ -126,19 +126,11 @@ router.post('/:message_id/delete', checkAuth, async (req, res) => {
|
|||
}
|
||||
|
||||
const channel = await getChannel(connection, message[0].channel_name);
|
||||
|
||||
if (user.id !== channel[0].owner_id && user.id !== message[0].user_id && user.admin !== 1) {
|
||||
connection.end();
|
||||
return res.status(401).send({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
if (message[0].reply_to_id) {
|
||||
const replies = await getMessageReplies(connection, message[0].reply_to_id);
|
||||
if (replies.length === 1) {
|
||||
await setHasReplies(connection, replyToId, false);
|
||||
}
|
||||
}
|
||||
|
||||
await deleteMessage(connection, message_id);
|
||||
connection.end();
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ export default function ChannelPage({socket}: {socket: WebSocket}) {
|
|||
const data = JSON.parse(event.data);
|
||||
if ((data.type === "new_message" || data.type === "delete_message" || data.type === "purge_channel") && data.channel_id === channel?.id) {
|
||||
axios
|
||||
.get(`/api/channels/${name}/messages`).then((res) => {
|
||||
.get(`/api/channels/${name}/messages?limit=${maxMessageToShown}`).then((res) => {
|
||||
setMessages(res.data)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue