mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
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:
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user