prevents a user who has had their chat privileges revoked from creating a public guild (#10205)

This commit is contained in:
Alys
2018-03-31 21:46:14 +10:00
committed by Matteo Pagliazzi
parent f3c041a561
commit bec8cb01e0
4 changed files with 43 additions and 4 deletions

View File

@@ -78,9 +78,10 @@ let api = {};
* "privacy": "private"
* }
*
* @apiError (400) {NotAuthorized} messageInsufficientGems User does not have enough gems (4)
* @apiError (400) {NotAuthorized} partyMustbePrivate Party must have privacy set to private
* @apiError (400) {NotAuthorized} messageGroupAlreadyInParty
* @apiError (401) {NotAuthorized} messageInsufficientGems User does not have enough gems (4)
* @apiError (401) {NotAuthorized} partyMustbePrivate Party must have privacy set to private
* @apiError (401) {NotAuthorized} messageGroupAlreadyInParty
* @apiError (401) {NotAuthorized} cannotCreatePublicGuildWhenMuted You cannot create a public guild because your chat privileges have been revoked.
*
* @apiSuccess (201) {Object} data The created group (See <a href="https://github.com/HabitRPG/habitica/blob/develop/website/server/models/group.js" target="_blank">/website/server/models/group.js</a>)
*
@@ -115,6 +116,7 @@ api.createGroup = {
group.leader = user._id;
if (group.type === 'guild') {
if (group.privacy === 'public' && user.flags.chatRevoked) throw new NotAuthorized(res.t('cannotCreatePublicGuildWhenMuted'));
if (user.balance < 1) throw new NotAuthorized(res.t('messageInsufficientGems'));
group.balance = 1;