mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #36011 from overleaf/jel-domain-capture-sales-email
[web] Weekly domain capture digest email GitOrigin-RevId: 6682d1d7fcbb179615dbc009d2da8266113a3b4b
This commit is contained in:
@@ -172,14 +172,38 @@ async function userIsMemberOfGroupSubscription(user) {
|
||||
/**
|
||||
* @param {any} subscription
|
||||
*/
|
||||
function teamHasReachedMemberLimit(subscription) {
|
||||
const currentTotal =
|
||||
function currentGroupTotal(subscription) {
|
||||
return (
|
||||
(subscription.member_ids || []).length +
|
||||
(subscription.teamInvites || []).length +
|
||||
(subscription.invited_emails || []).length
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} subscription
|
||||
*/
|
||||
function teamHasReachedMemberLimit(subscription) {
|
||||
const currentTotal = currentGroupTotal(subscription)
|
||||
|
||||
return currentTotal >= subscription.membersLimit
|
||||
}
|
||||
/**
|
||||
* Calculate the number of remaining seats for a group subscription.
|
||||
*
|
||||
* @param {any} subscriptionId - The subscription ID
|
||||
* @returns {Promise<number>} - Remaining seats (membersLimit - current members/invites)
|
||||
*/
|
||||
async function remainingSeatsForGroup(subscriptionId) {
|
||||
const subscription =
|
||||
await SubscriptionLocator.promises.getSubscription(subscriptionId)
|
||||
if (!subscription) {
|
||||
logger.warn({ subscriptionId }, 'no subscription found')
|
||||
throw new Error('no subscription found')
|
||||
}
|
||||
const currentTotal = currentGroupTotal(subscription)
|
||||
return subscription.membersLimit - currentTotal
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} subscriptionId
|
||||
@@ -241,6 +265,7 @@ const LimitationsManager = {
|
||||
userHasSubscription,
|
||||
userIsMemberOfGroupSubscription,
|
||||
hasGroupMembersLimitReached,
|
||||
remainingSeatsForGroup,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user