From da08b6c814645256e87a6eee60af908c8407a59b Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Tue, 22 Mar 2016 16:10:17 -0500 Subject: [PATCH] Removed group query from route --- .../groups/POST-groups_groupId_reject.test.js | 11 ----------- website/src/controllers/api-v3/groups.js | 10 ++++------ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js b/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js index 27018c24fe..18f83fe9c9 100644 --- a/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js +++ b/test/api/v3/integration/groups/POST-groups_groupId_reject.test.js @@ -3,19 +3,8 @@ import { createAndPopulateGroup, translate as t, } from '../../../../helpers/api-v3-integration.helper'; -import { v4 as generateUUID } from 'uuid'; describe('POST /group/:groupId/reject-invite', () => { - it('returns error when groupId is not for a valid group', async () => { - let userToRejectInvite = await generateUser(); - - await expect(userToRejectInvite.post(`/groups/${generateUUID()}/reject-invite`)).to.eventually.be.rejected.and.eql({ - code: 404, - error: 'NotFound', - message: t('groupNotFound'), - }); - }); - context('Rejecting a public guild invite', () => { let publicGuild, invitedUser; diff --git a/website/src/controllers/api-v3/groups.js b/website/src/controllers/api-v3/groups.js index 6be847a813..7850236ead 100644 --- a/website/src/controllers/api-v3/groups.js +++ b/website/src/controllers/api-v3/groups.js @@ -329,17 +329,15 @@ api.rejectGroupInvite = { let validationErrors = req.validationErrors(); if (validationErrors) throw validationErrors; - let group = await Group.getGroup({user, groupId: req.params.groupId, optionalMembership: true}); // Do not fetch chat and work even if the user is not yet a member of the group - if (!group) throw new NotFound(res.t('groupNotFound')); - + let groupId = req.params.groupId; let isUserInvited = false; - if (group.type === 'party' && group._id === user.invitations.party.id) { + if (groupId === user.invitations.party.id) { user.invitations.party = {}; user.markModified('invitations.party'); isUserInvited = true; - } else if (group.type === 'guild') { - let hasInvitation = removeFromArray(user.invitations.guilds, { id: group._id }); + } else { + let hasInvitation = removeFromArray(user.invitations.guilds, { id: groupId }); if (hasInvitation) { isUserInvited = true;