mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
fix: remove guild or party when user looks it up if it does not exist
closes #7878 fixes #7724
This commit is contained in:
@@ -159,6 +159,17 @@ schema.statics.getGroup = async function getGroup (options = {}) {
|
||||
if (fields) mQuery.select(fields);
|
||||
if (populateLeader === true) mQuery.populate('leader', nameFields);
|
||||
let group = await mQuery.exec();
|
||||
|
||||
if (!group) {
|
||||
if (groupId === user.party._id) {
|
||||
// reset party object to default state
|
||||
user.party = {};
|
||||
} else {
|
||||
removeFromArray(user.guilds, groupId);
|
||||
}
|
||||
await user.save();
|
||||
}
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user