Fix errors

This commit is contained in:
Mateus Etto
2018-02-18 19:44:17 +09:00
parent 3171550de2
commit 7af71d1457
2 changed files with 9 additions and 6 deletions

View File

@@ -74,7 +74,8 @@ api.getChat = {
let group = await Group.getGroup({user, groupId: req.params.groupId, fields: 'chat'});
if (!group) throw new NotFound(res.t('groupNotFound'));
res.respond(200, await Group.toJSONCleanChat(group, user).chat);
let toJSON = await Group.toJSONCleanChat(group, user);
res.respond(200, toJSON.chat);
},
};
@@ -194,7 +195,8 @@ api.postChat = {
}
if (chatUpdated) {
res.respond(200, {chat: await Group.toJSONCleanChat(savedGroup, user).chat});
let toJSON = await Group.toJSONCleanChat(savedGroup, user);
res.respond(200, {chat: toJSON.chat});
} else {
res.respond(200, {message: savedGroup.chat[0]});
}
@@ -486,7 +488,8 @@ api.deleteChat = {
).exec();
if (chatUpdated) {
let chatRes = await Group.toJSONCleanChat(group, user).chat;
let toJSON = await Group.toJSONCleanChat(group, user);
let chatRes = toJSON.chat;
removeFromArray(chatRes, {id: chatId});
res.respond(200, chatRes);
} else {

View File

@@ -331,9 +331,9 @@ async function translateSystemMessages (group, user) {
}
await Bluebird.map(Object.keys(usernames), async (username) => {
let usr = await User
.findById(username)
.select(nameFields)
.exec();
.findById(username)
.select(nameFields)
.exec();
usernames[username] = usr.profile.name;
});
for (let i = 0; i < group.chat.length; i++) {