allow liking their own message (#15117)

This commit is contained in:
negue
2024-02-05 21:55:46 +01:00
committed by GitHub
parent 2fa26db93f
commit 8b373b9283
3 changed files with 14 additions and 16 deletions

View File

@@ -232,7 +232,6 @@ api.postChat = {
* @apiUse MessageNotFound
* @apiUse GroupIdRequired
* @apiUse ChatIdRequired
* @apiError (400) {NotFound} messageGroupChatLikeOwnMessage A user can't like their own message
*/
api.likeChat = {
method: 'POST',
@@ -253,10 +252,8 @@ api.likeChat = {
const message = await Chat.findOne({ _id: req.params.chatId }).exec();
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
// @TODO correct this error type
if (message.uuid === user._id) throw new NotFound(res.t('messageGroupChatLikeOwnMessage'));
if (!message.likes) message.likes = {};
message.likes[user._id] = !message.likes[user._id];
message.markModified('likes');
await message.save();