overleaf/services/web/app/coffee/Features/Institutions/InstitutionsGetter.coffee
2018-08-27 15:45:31 +02:00

14 lines
534 B
CoffeeScript

UserGetter = require '../User/UserGetter'
logger = require 'logger-sharelatex'
module.exports = InstitutionsGetter =
getConfirmedInstitutions: (userId, callback = (error, institutions) ->) ->
UserGetter.getUserFullEmails userId, (error, emailsData) ->
return callback error if error?
confirmedInstitutions = emailsData.filter (emailData) ->
emailData.confirmedAt? and emailData.affiliation?.institution?.confirmed
.map (emailData) ->
emailData.affiliation?.institution
callback(null, confirmedInstitutions)