1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-11 07:45:12 +00:00

Merge pull request from overleaf/ta-limit-affiliation-rate

Limit the Number of Affiliations Created Simultaneously

GitOrigin-RevId: 242d3f3a2859eb2114f43091e7ca52534b282396
This commit is contained in:
Timothée Alby 2019-06-11 15:15:04 +02:00 committed by sharelatex
parent e659703745
commit 4583c25b1b

View file

@ -17,6 +17,7 @@ const UserGetter = require('../User/UserGetter')
const { addAffiliation } = require('../Institutions/InstitutionsAPI')
const FeaturesUpdater = require('../Subscription/FeaturesUpdater')
const async = require('async')
const ASYNC_AFFILIATIONS_LIMIT = 10
module.exports = InstitutionsController = {
confirmDomain(req, res, next) {
@ -48,8 +49,9 @@ var affiliateUsers = function(hostname, callback) {
return callback(error)
}
return async.map(
return async.mapLimit(
users,
ASYNC_AFFILIATIONS_LIMIT,
(user, innerCallback) =>
affiliateUserByReversedHostname(
user,
@ -70,7 +72,7 @@ var affiliateUserByReversedHostname = function(
const matchingEmails = user.emails.filter(
email => email.reversedHostname === reversedHostname
)
return async.map(
return async.mapSeries(
matchingEmails,
(email, innerCallback) =>
addAffiliation(