WIP. Accepting a redundant party invite will not remove the user from the party and let the user still be a part of it. Fixes #12291. (#12356)

* Getting the latest code

* Temporary fix for Redundant Party Invite. Needs changes.

* Added logic to check if the user is an existing member of the party that the user is invited to.

* Added a test case for redundant party invite check.

* Changed the test case for redundant party invite to see if it runs successfully.

* Made changes to the test cases.

* Fixed lint errors.

* Removed the exclusive mocha test.

* Referred the issue in the name of the new test case.

* Modified test case to check its veracity.

* Checking if the update statement is working or not.
This commit is contained in:
Jalansh
2020-07-13 19:30:34 +05:30
committed by GitHub
parent 616a0b7509
commit a02c4c1cfd
2 changed files with 23 additions and 10 deletions

View File

@@ -544,20 +544,23 @@ api.joinGroup = {
// Check if was invited to party
const inviterParty = _.find(user.invitations.parties, { id: group._id });
if (inviterParty) {
inviter = inviterParty.inviter;
// Check if the user is already a member of the party or not. Only make the user leave the
// party if the user is not a member of the party. See #12291 for more details.
if (user.party._id !== group._id) {
inviter = inviterParty.inviter;
// If user was in a different party (when partying solo you can be invited to a new party)
// make them leave that party before doing anything
if (user.party._id) {
const userPreviousParty = await Group.getGroup({ user, groupId: user.party._id });
// If user was in a different party (when partying solo you can be invited to a new party)
// make them leave that party before doing anything
if (user.party._id) {
const userPreviousParty = await Group.getGroup({ user, groupId: user.party._id });
if (userPreviousParty.memberCount === 1 && user.party.quest.key) {
throw new NotAuthorized(res.t('messageCannotLeaveWhileQuesting'));
if (userPreviousParty.memberCount === 1 && user.party.quest.key) {
throw new NotAuthorized(res.t('messageCannotLeaveWhileQuesting'));
}
if (userPreviousParty) await userPreviousParty.leave(user);
}
if (userPreviousParty) await userPreviousParty.leave(user);
}
// Clear all invitations of new user
user.invitations.parties = [];
user.invitations.party = {};