mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
Removed group query from route
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user