fix(groups): fix TypeError when missing

This commit is contained in:
Sabe Jones
2024-02-05 18:06:18 -06:00
parent bccfaab350
commit 8b3267458b

View File

@@ -75,10 +75,10 @@ api.getChat = {
const { groupId } = req.params; const { groupId } = req.params;
const group = await Group.getGroup({ user, groupId, fields: 'chat privacy' }); const group = await Group.getGroup({ user, groupId, fields: 'chat privacy' });
if (!group) throw new NotFound(res.t('groupNotFound'));
if (group.privacy === 'public') { if (group.privacy === 'public') {
throw new BadRequest(res.t('featureRetired')); throw new BadRequest(res.t('featureRetired'));
} }
if (!group) throw new NotFound(res.t('groupNotFound'));
const groupChat = await Group.toJSONCleanChat(group, user); const groupChat = await Group.toJSONCleanChat(group, user);
res.respond(200, groupChat.chat); res.respond(200, groupChat.chat);