mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Removed group query from route
This commit is contained in:
@@ -3,19 +3,8 @@ import {
|
|||||||
createAndPopulateGroup,
|
createAndPopulateGroup,
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-v3-integration.helper';
|
} from '../../../../helpers/api-v3-integration.helper';
|
||||||
import { v4 as generateUUID } from 'uuid';
|
|
||||||
|
|
||||||
describe('POST /group/:groupId/reject-invite', () => {
|
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', () => {
|
context('Rejecting a public guild invite', () => {
|
||||||
let publicGuild, invitedUser;
|
let publicGuild, invitedUser;
|
||||||
|
|
||||||
|
|||||||
@@ -329,17 +329,15 @@ api.rejectGroupInvite = {
|
|||||||
let validationErrors = req.validationErrors();
|
let validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw 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
|
let groupId = req.params.groupId;
|
||||||
if (!group) throw new NotFound(res.t('groupNotFound'));
|
|
||||||
|
|
||||||
let isUserInvited = false;
|
let isUserInvited = false;
|
||||||
|
|
||||||
if (group.type === 'party' && group._id === user.invitations.party.id) {
|
if (groupId === user.invitations.party.id) {
|
||||||
user.invitations.party = {};
|
user.invitations.party = {};
|
||||||
user.markModified('invitations.party');
|
user.markModified('invitations.party');
|
||||||
isUserInvited = true;
|
isUserInvited = true;
|
||||||
} else if (group.type === 'guild') {
|
} else {
|
||||||
let hasInvitation = removeFromArray(user.invitations.guilds, { id: group._id });
|
let hasInvitation = removeFromArray(user.invitations.guilds, { id: groupId });
|
||||||
|
|
||||||
if (hasInvitation) {
|
if (hasInvitation) {
|
||||||
isUserInvited = true;
|
isUserInvited = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user