mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #6137 from overleaf/jpa-cleanup-cb-based-interface
[web] SubscriptionLocator: do not return promises from cb-based methods GitOrigin-RevId: afbdbf77ea672064d791915ac4119e4b6f5cce74
This commit is contained in:
parent
108c99cf53
commit
f88d63c54a
1 changed files with 13 additions and 19 deletions
|
@ -1,8 +1,6 @@
|
||||||
/* eslint-disable
|
/* eslint-disable
|
||||||
camelcase,
|
camelcase,
|
||||||
node/handle-callback-err,
|
|
||||||
max-len,
|
max-len,
|
||||||
no-unused-vars,
|
|
||||||
*/
|
*/
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
// Fix any style issues and re-enable lint.
|
// Fix any style issues and re-enable lint.
|
||||||
|
@ -21,22 +19,19 @@ require('./GroupPlansData') // make sure dynamic group plans are loaded
|
||||||
const SubscriptionLocator = {
|
const SubscriptionLocator = {
|
||||||
getUsersSubscription(user_or_id, callback) {
|
getUsersSubscription(user_or_id, callback) {
|
||||||
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
||||||
return Subscription.findOne(
|
Subscription.findOne({ admin_id: user_id }, function (err, subscription) {
|
||||||
{ admin_id: user_id },
|
logger.log({ user_id }, 'got users subscription')
|
||||||
function (err, subscription) {
|
callback(err, subscription)
|
||||||
logger.log({ user_id }, 'got users subscription')
|
})
|
||||||
return callback(err, subscription)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserIndividualSubscription(user_or_id, callback) {
|
getUserIndividualSubscription(user_or_id, callback) {
|
||||||
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
||||||
return Subscription.findOne(
|
Subscription.findOne(
|
||||||
{ admin_id: user_id, groupPlan: false },
|
{ admin_id: user_id, groupPlan: false },
|
||||||
function (err, subscription) {
|
function (err, subscription) {
|
||||||
logger.log({ user_id }, 'got users individual subscription')
|
logger.log({ user_id }, 'got users individual subscription')
|
||||||
return callback(err, subscription)
|
callback(err, subscription)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -45,8 +40,7 @@ const SubscriptionLocator = {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
Subscription.find({
|
||||||
return Subscription.find({
|
|
||||||
manager_ids: user_or_id,
|
manager_ids: user_or_id,
|
||||||
groupPlan: true,
|
groupPlan: true,
|
||||||
})
|
})
|
||||||
|
@ -56,17 +50,17 @@ const SubscriptionLocator = {
|
||||||
|
|
||||||
getMemberSubscriptions(user_or_id, callback) {
|
getMemberSubscriptions(user_or_id, callback) {
|
||||||
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
const user_id = SubscriptionLocator._getUserId(user_or_id)
|
||||||
return Subscription.find({ member_ids: user_id })
|
Subscription.find({ member_ids: user_id })
|
||||||
.populate('admin_id')
|
.populate('admin_id')
|
||||||
.exec(callback)
|
.exec(callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubscription(subscription_id, callback) {
|
getSubscription(subscription_id, callback) {
|
||||||
return Subscription.findOne({ _id: subscription_id }, callback)
|
Subscription.findOne({ _id: subscription_id }, callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubscriptionByMemberIdAndId(user_id, subscription_id, callback) {
|
getSubscriptionByMemberIdAndId(user_id, subscription_id, callback) {
|
||||||
return Subscription.findOne(
|
Subscription.findOne(
|
||||||
{ member_ids: user_id, _id: subscription_id },
|
{ member_ids: user_id, _id: subscription_id },
|
||||||
{ _id: 1 },
|
{ _id: 1 },
|
||||||
callback
|
callback
|
||||||
|
@ -74,7 +68,7 @@ const SubscriptionLocator = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getGroupSubscriptionsMemberOf(user_id, callback) {
|
getGroupSubscriptionsMemberOf(user_id, callback) {
|
||||||
return Subscription.find(
|
Subscription.find(
|
||||||
{ member_ids: user_id },
|
{ member_ids: user_id },
|
||||||
{ _id: 1, planCode: 1 },
|
{ _id: 1, planCode: 1 },
|
||||||
callback
|
callback
|
||||||
|
@ -82,11 +76,11 @@ const SubscriptionLocator = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getGroupsWithEmailInvite(email, callback) {
|
getGroupsWithEmailInvite(email, callback) {
|
||||||
return Subscription.find({ invited_emails: email }, callback)
|
Subscription.find({ invited_emails: email }, callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
getGroupWithV1Id(v1TeamId, callback) {
|
getGroupWithV1Id(v1TeamId, callback) {
|
||||||
return Subscription.findOne({ 'overleaf.id': v1TeamId }, callback)
|
Subscription.findOne({ 'overleaf.id': v1TeamId }, callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserDeletedSubscriptions(userId, callback) {
|
getUserDeletedSubscriptions(userId, callback) {
|
||||||
|
|
Loading…
Reference in a new issue