chat: use _id instead of id when finding doc (#10278)

This commit is contained in:
Matteo Pagliazzi 2018-04-24 15:10:20 +02:00 committed by GitHub
parent b10f056a73
commit 46d6590fec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -235,7 +235,7 @@ api.likeChat = {
let group = await Group.getGroup({user, groupId});
if (!group) throw new NotFound(res.t('groupNotFound'));
let message = await Chat.findOne({id: req.params.chatId}).exec();
let 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'));
@ -330,7 +330,7 @@ api.clearChatFlags = {
});
if (!group) throw new NotFound(res.t('groupNotFound'));
let message = await Chat.findOne({id: chatId}).exec();
let message = await Chat.findOne({_id: chatId}).exec();
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
message.flagCount = 0;
@ -458,7 +458,7 @@ api.deleteChat = {
let group = await Group.getGroup({user, groupId, fields: 'chat'});
if (!group) throw new NotFound(res.t('groupNotFound'));
let message = await Chat.findOne({id: chatId}).exec();
let message = await Chat.findOne({_id: chatId}).exec();
if (!message) throw new NotFound(res.t('messageGroupChatNotFound'));
if (user._id !== message.uuid && !user.contributor.admin) {

View file

@ -37,7 +37,7 @@ export default class GroupChatReporter extends ChatReporter {
});
if (!group) throw new NotFound(this.res.t('groupNotFound'));
const message = await Chat.findOne({id: this.req.params.chatId}).exec();
const message = await Chat.findOne({_id: this.req.params.chatId}).exec();
if (!message) throw new NotFound(this.res.t('messageGroupChatNotFound'));
if (message.uuid === 'system') throw new BadRequest(this.res.t('messageCannotFlagSystemMessages', {communityManagerEmail: COMMUNITY_MANAGER_EMAIL}));