mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-17 20:19:16 +00:00
Merge pull request #7828 from overleaf/ab-subscriptiongroupcontroller-cleanup
[web] Decaf cleanup SubscriptionGroupController GitOrigin-RevId: eb407c52e77db50481356c342fc685f30145fc23
This commit is contained in:
parent
cf0b46ecf2
commit
e9e429d339
1 changed files with 54 additions and 65 deletions
|
@ -1,73 +1,62 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const SubscriptionGroupHandler = require('./SubscriptionGroupHandler')
|
||||
const OError = require('@overleaf/o-error')
|
||||
const logger = require('@overleaf/logger')
|
||||
const SubscriptionLocator = require('./SubscriptionLocator')
|
||||
const SessionManager = require('../Authentication/SessionManager')
|
||||
const _ = require('underscore')
|
||||
const async = require('async')
|
||||
|
||||
function removeUserFromGroup(req, res, next) {
|
||||
const subscription = req.entity
|
||||
const userToRemoveId = req.params.user_id
|
||||
logger.log(
|
||||
{ subscriptionId: subscription._id, userToRemove_id: userToRemoveId },
|
||||
'removing user from group subscription'
|
||||
)
|
||||
SubscriptionGroupHandler.removeUserFromGroup(
|
||||
subscription._id,
|
||||
userToRemoveId,
|
||||
function (error) {
|
||||
if (error) {
|
||||
OError.tag(error, 'error removing user from group', {
|
||||
subscriptionId: subscription._id,
|
||||
userToRemove_id: userToRemoveId,
|
||||
})
|
||||
return next(error)
|
||||
}
|
||||
|
||||
res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function removeSelfFromGroup(req, res, next) {
|
||||
const subscriptionId = req.query.subscriptionId
|
||||
const userToRemoveId = SessionManager.getLoggedInUserId(req.session)
|
||||
SubscriptionLocator.getSubscription(
|
||||
subscriptionId,
|
||||
function (error, subscription) {
|
||||
if (error) {
|
||||
return next(error)
|
||||
}
|
||||
|
||||
SubscriptionGroupHandler.removeUserFromGroup(
|
||||
subscription._id,
|
||||
userToRemoveId,
|
||||
function (error) {
|
||||
if (error) {
|
||||
logger.err(
|
||||
{ err: error, userToRemove_id: userToRemoveId, subscriptionId },
|
||||
'error removing self from group'
|
||||
)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
removeUserFromGroup(req, res, next) {
|
||||
const subscription = req.entity
|
||||
const userToRemove_id = req.params.user_id
|
||||
logger.log(
|
||||
{ subscriptionId: subscription._id, userToRemove_id },
|
||||
'removing user from group subscription'
|
||||
)
|
||||
return SubscriptionGroupHandler.removeUserFromGroup(
|
||||
subscription._id,
|
||||
userToRemove_id,
|
||||
function (err) {
|
||||
if (err != null) {
|
||||
OError.tag(err, 'error removing user from group', {
|
||||
subscriptionId: subscription._id,
|
||||
userToRemove_id,
|
||||
})
|
||||
return next(err)
|
||||
}
|
||||
return res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
removeSelfFromGroup(req, res, next) {
|
||||
const subscriptionId = req.query.subscriptionId
|
||||
const userToRemove_id = SessionManager.getLoggedInUserId(req.session)
|
||||
return SubscriptionLocator.getSubscription(
|
||||
subscriptionId,
|
||||
function (error, subscription) {
|
||||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
|
||||
return SubscriptionGroupHandler.removeUserFromGroup(
|
||||
subscription._id,
|
||||
userToRemove_id,
|
||||
function (err) {
|
||||
if (err != null) {
|
||||
logger.err(
|
||||
{ err, userToRemove_id, subscriptionId },
|
||||
'error removing self from group'
|
||||
)
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
return res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
removeUserFromGroup,
|
||||
removeSelfFromGroup,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue