mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
18 lines
736 B
CoffeeScript
18 lines
736 B
CoffeeScript
|
logger = require 'logger-sharelatex'
|
||
|
async = require 'async'
|
||
|
db = require("../../infrastructure/mongojs").db
|
||
|
ObjectId = require("../../infrastructure/mongojs").ObjectId
|
||
|
{ getInstitutionAffiliations } = require('./InstitutionsAPI')
|
||
|
FeaturesUpdater = require('../Subscription/FeaturesUpdater')
|
||
|
|
||
|
ASYNC_LIMIT = 10
|
||
|
module.exports = InstitutionsManager =
|
||
|
upgradeInstitutionUsers: (institutionId, callback = (error) ->) ->
|
||
|
getInstitutionAffiliations institutionId, (error, affiliations) ->
|
||
|
return callback(error) if error
|
||
|
async.eachLimit affiliations, ASYNC_LIMIT, refreshFeatures, callback
|
||
|
|
||
|
refreshFeatures = (affiliation, callback) ->
|
||
|
userId = ObjectId(affiliation.user_id)
|
||
|
FeaturesUpdater.refreshFeatures(userId, true, callback)
|