mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Merge branch 'develop' into release
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 = {};
|
||||
@@ -603,7 +606,14 @@ api.joinGroup = {
|
||||
group.leader = user._id; // If new user is only member -> set as leader
|
||||
}
|
||||
|
||||
group.memberCount += 1;
|
||||
if (group.type === 'party') {
|
||||
// For parties we count the number of members from the database to get the correct value.
|
||||
// See #12275 on why this is necessary and only done for parties.
|
||||
const currentMembers = await group.getMemberCount();
|
||||
group.memberCount = currentMembers + 1;
|
||||
} else {
|
||||
group.memberCount += 1;
|
||||
}
|
||||
|
||||
let promises = [group.save(), user.save()];
|
||||
|
||||
@@ -948,7 +958,14 @@ api.removeGroupMember = {
|
||||
}
|
||||
|
||||
if (isInGroup) {
|
||||
group.memberCount -= 1;
|
||||
// For parties we count the number of members from the database to get the correct value.
|
||||
// See #12275 on why this is necessary and only done for parties.
|
||||
if (group.type === 'party') {
|
||||
const currentMembers = await group.getMemberCount();
|
||||
group.memberCount = currentMembers - 1;
|
||||
} else {
|
||||
group.memberCount -= 1;
|
||||
}
|
||||
|
||||
if (group.quest && group.quest.leader === member._id) {
|
||||
group.quest.key = undefined;
|
||||
|
||||
@@ -862,9 +862,14 @@ api.equip = {
|
||||
*
|
||||
* @apiParam (Path) {String} pet
|
||||
* @apiParam (Path) {String} food
|
||||
* @apiParam (Query) {Number} [amount] The amount of food to feed.
|
||||
* Note: Pet can eat 50 units.
|
||||
* Preferred food offers 5 units per food,
|
||||
* other food 2 units.
|
||||
*
|
||||
* @apiParamExample {url} Example-URL
|
||||
* https://habitica.com/api/v3/user/feed/Armadillo-Shade/Chocolate
|
||||
* https://habitica.com/api/v3/user/feed/Armadillo-Shade/Chocolate?amount=9
|
||||
*
|
||||
* @apiSuccess {Number} data The pet value
|
||||
* @apiSuccess {String} message Success message
|
||||
@@ -877,6 +882,8 @@ api.equip = {
|
||||
* @apiError {BadRequest} InvalidPet Invalid pet name supplied.
|
||||
* @apiError {NotFound} FoodNotOwned :food not found in user.items.food
|
||||
* Note: also sent if food name is invalid.
|
||||
* @apiError {NotAuthorized} notEnoughFood :Not enough food to feed the pet as requested.
|
||||
* @apiError {NotAuthorized} tooMuchFood :You try to feed too much food. Action ancelled.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -223,6 +223,10 @@ api.updateWebhook = {
|
||||
|
||||
webhook.formatOptions(res);
|
||||
|
||||
// Tell Mongoose that the webhook's options have been modified
|
||||
// so it actually commits the options changes to the database
|
||||
webhook.markModified('options');
|
||||
|
||||
await user.save();
|
||||
res.respond(200, webhook);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user