2018-08-10 07:40:25 -04:00
|
|
|
InstitutionsGetter = require './InstitutionsGetter'
|
2018-07-10 05:42:17 -04:00
|
|
|
PlansLocator = require '../Subscription/PlansLocator'
|
|
|
|
Settings = require 'settings-sharelatex'
|
|
|
|
logger = require 'logger-sharelatex'
|
|
|
|
|
|
|
|
module.exports = InstitutionsFeatures =
|
|
|
|
getInstitutionsFeatures: (userId, callback = (error, features) ->) ->
|
|
|
|
InstitutionsFeatures.hasLicence userId, (error, hasLicence) ->
|
|
|
|
return callback error if error?
|
|
|
|
return callback(null, {}) unless hasLicence
|
|
|
|
plan = PlansLocator.findLocalPlanInSettings Settings.institutionPlanCode
|
|
|
|
callback(null, plan?.features or {})
|
|
|
|
|
|
|
|
|
|
|
|
hasLicence: (userId, callback = (error, hasLicence) ->) ->
|
2018-08-10 07:40:25 -04:00
|
|
|
InstitutionsGetter.getConfirmedInstitutions userId, (error, institutions) ->
|
2018-07-10 05:42:17 -04:00
|
|
|
return callback error if error?
|
|
|
|
|
2018-08-10 07:40:25 -04:00
|
|
|
hasLicence = institutions.some (institution) ->
|
|
|
|
institution.licence and institution.licence != 'free'
|
2018-07-10 05:42:17 -04:00
|
|
|
|
2018-08-10 07:40:25 -04:00
|
|
|
callback(null, hasLicence)
|