mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
Leaving a group (#8517)
* Leaving a group or a guild no longer removes the user from the challenges of that group or guild. * Updating api docs for leaving group to take into account the default path no longer leaving challenges when leaving a group. * Updating api docs for leaving group to take into account the default path no longer leaving challenges when leaving a group. * refactored according to blade's comments to not be a breaking change. The api now accepts a body parameter to specify wether the user should remain in the groups challenges or leave them. The change also adds more tests around this behavior to confirm that it works as expected.
This commit is contained in:
@@ -524,7 +524,8 @@ function _removeMessagesFromMember (member, groupId) {
|
||||
* @apiGroup Group
|
||||
*
|
||||
* @apiParam {String} groupId The group _id ('party' for the user party and 'habitrpg' for tavern are accepted)
|
||||
* @apiParam {String="remove-all","keep-all"} keep Query parameter - Whether to keep or not challenges' tasks. Defaults to keep-all
|
||||
* @apiParam (Query) {String="remove-all","keep-all"} keep=keep-all Whether or not to keep challenge tasks belonging to the group being left.
|
||||
* @apiParam (Body) {String="remain-in-challenges","leave-challenges"} [keepChallenges=leave-challenges] Whether or not to remain in the challenges of the group being left.
|
||||
*
|
||||
* @apiSuccess {Object} data An empty object
|
||||
*
|
||||
@@ -539,6 +540,7 @@ api.leaveGroup = {
|
||||
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty();
|
||||
// When removing the user from challenges, should we keep the tasks?
|
||||
req.checkQuery('keep', res.t('keepOrRemoveAll')).optional().isIn(['keep-all', 'remove-all']);
|
||||
req.checkBody('keepChallenges', res.t('remainOrLeaveChallenges')).optional().isIn(['remain-in-challenges', 'leave-challenges']);
|
||||
|
||||
let validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
@@ -560,7 +562,7 @@ api.leaveGroup = {
|
||||
}
|
||||
}
|
||||
|
||||
await group.leave(user, req.query.keep);
|
||||
await group.leave(user, req.query.keep, req.body.keepChallenges);
|
||||
|
||||
if (group.purchased.plan && group.purchased.plan.customerId) await payments.updateStripeGroupPlan(group);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user