mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Honour invited_emails for the team being
We'll remove them soon, but we want to keep them for a while so recent invites can join their teams.
This commit is contained in:
parent
670f24ef6f
commit
a3bb99d755
5 changed files with 30 additions and 4 deletions
|
@ -56,7 +56,10 @@ module.exports = LimitationsManager =
|
|||
callback err, subscriptions.length > 0, subscriptions
|
||||
|
||||
teamHasReachedMemberLimit: (subscription) ->
|
||||
currentTotal = (subscription.member_ids or []).length + (subscription.teamInvites or []).length
|
||||
currentTotal = (subscription.member_ids or []).length
|
||||
+ (subscription.teamInvites or []).length
|
||||
+ (subscription.invited_emails or []).length
|
||||
|
||||
return currentTotal >= subscription.membersLimit
|
||||
|
||||
hasGroupMembersLimitReached: (user_id, callback = (err, limitReached, subscription)->)->
|
||||
|
|
|
@ -47,6 +47,9 @@ module.exports = SubscriptionGroupHandler =
|
|||
|
||||
users = []
|
||||
|
||||
for email in subscription.invited_emails or []
|
||||
users.push buildEmailInviteViewModel(email)
|
||||
|
||||
for teamInvite in subscription.teamInvites or []
|
||||
users.push buildEmailInviteViewModel(teamInvite.email)
|
||||
|
||||
|
|
|
@ -47,6 +47,13 @@ module.exports = SubscriptionUpdater =
|
|||
return callback(err)
|
||||
FeaturesUpdater.refreshFeatures user_id, callback
|
||||
|
||||
removeEmailInviteFromGroup: (adminUser_id, email, callback)->
|
||||
Subscription.update {
|
||||
admin_id: adminUser_id
|
||||
}, "$pull": {
|
||||
invited_emails: email
|
||||
}, callback
|
||||
|
||||
deleteSubscription: (subscription_id, callback = (error) ->) ->
|
||||
SubscriptionLocator.getSubscription subscription_id, (err, subscription) ->
|
||||
return callback(err) if err?
|
||||
|
|
|
@ -110,10 +110,18 @@ createInvite = (subscription, email, inviterName, callback) ->
|
|||
return callback(error, invite)
|
||||
|
||||
removeInviteFromTeam = (subscriptionId, email, callback) ->
|
||||
searchConditions = { _id: new ObjectId(subscriptionId.toString()) }
|
||||
updateOp = { $pull: { teamInvites: { email: email.trim().toLowerCase() } } }
|
||||
email = email.trim().toLowerCase()
|
||||
|
||||
searchConditions = { _id: new ObjectId(subscriptionId.toString()) }
|
||||
|
||||
removeInvite = { $pull: { teamInvites: { email: email } } }
|
||||
removeLegacyInvite = { $pull: { invited_emails: email } }
|
||||
|
||||
async.series [
|
||||
(cb) -> Subscription.update(searchConditions, removeInvite, cb),
|
||||
(cb) -> Subscription.update(searchConditions, removeLegacyInvite, cb),
|
||||
], callback
|
||||
|
||||
Subscription.update(searchConditions, updateOp, callback)
|
||||
|
||||
checkIfInviteIsPossible = (subscription, email, callback = (error, possible, reason) -> ) ->
|
||||
if LimitationsManager.teamHasReachedMemberLimit(subscription)
|
||||
|
|
|
@ -201,6 +201,11 @@ describe "TeamInvitesHandler", ->
|
|||
{ _id: new ObjectId("55153a8014829a865bbf700d") },
|
||||
{ '$pull': { teamInvites: { email: "jorah@mormont.org" } } }
|
||||
).should.eq true
|
||||
|
||||
@Subscription.update.calledWith(
|
||||
{ _id: new ObjectId("55153a8014829a865bbf700d") },
|
||||
{ '$pull': { invited_emails: "jorah@mormont.org" } }
|
||||
).should.eq true
|
||||
done()
|
||||
|
||||
describe "createTeamInvitesForLegacyInvitedEmail", (done) ->
|
||||
|
|
Loading…
Reference in a new issue