mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
fix: removing party invitations
This commit is contained in:
@@ -120,11 +120,13 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can remove other invites', async () => {
|
it('can remove other invites', async () => {
|
||||||
|
expect(partyInvitedUser.invitations.party).to.not.be.empty;
|
||||||
|
|
||||||
await partyleader.post(`/groups/${party._id}/removeMember/${partyInvitedUser._id}`);
|
await partyleader.post(`/groups/${party._id}/removeMember/${partyInvitedUser._id}`);
|
||||||
|
|
||||||
let invitedUserWithoutInvite = await partyInvitedUser.get('/user');
|
let invitedUserWithoutInvite = await partyInvitedUser.get('/user');
|
||||||
|
|
||||||
expect(_.findIndex(invitedUserWithoutInvite.invitations.party, {id: party._id})).eql(-1);
|
expect(invitedUserWithoutInvite.invitations.party).to.be.empty;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -128,6 +128,10 @@ export async function createAndPopulateGroup (settings = {}) {
|
|||||||
|
|
||||||
await Bluebird.all(invitationPromises);
|
await Bluebird.all(invitationPromises);
|
||||||
|
|
||||||
|
await Bluebird.all(invitees.map((invitee) => {
|
||||||
|
return invitee.sync();
|
||||||
|
}));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
groupLeader,
|
groupLeader,
|
||||||
group,
|
group,
|
||||||
|
|||||||
@@ -466,8 +466,8 @@ api.removeGroupMember = {
|
|||||||
removeFromArray(member.invitations.guilds, { id: group._id });
|
removeFromArray(member.invitations.guilds, { id: group._id });
|
||||||
}
|
}
|
||||||
if (isInvited === 'party') {
|
if (isInvited === 'party') {
|
||||||
user.invitations.party = {};
|
member.invitations.party = {};
|
||||||
user.markModified('invitations.party');
|
member.markModified('invitations.party');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new NotFound(res.t('groupMemberNotFound'));
|
throw new NotFound(res.t('groupMemberNotFound'));
|
||||||
@@ -514,6 +514,7 @@ async function _inviteByUUID (uuid, group, inviter, req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userToInvite.invitations.party = {id: group._id, name: group.name, inviter: inviter._id};
|
userToInvite.invitations.party = {id: group._id, name: group.name, inviter: inviter._id};
|
||||||
|
return userToInvite.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
let groupLabel = group.type === 'guild' ? 'Guild' : 'Party';
|
let groupLabel = group.type === 'guild' ? 'Guild' : 'Party';
|
||||||
|
|||||||
Reference in New Issue
Block a user