mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-03 23:52:09 +00:00
24 lines
No EOL
869 B
CoffeeScript
24 lines
No EOL
869 B
CoffeeScript
request = require 'request'
|
|
settings = require 'settings-sharelatex'
|
|
logger = require 'logger-sharelatex'
|
|
Errors = require '../Errors/Errors'
|
|
oAuthRequest = require '../../../../modules/overleaf-integration-web-module/app/coffee/oauth/OAuthRequest'
|
|
|
|
makeRequest = (opts, callback) ->
|
|
if settings.apis?.olProjects?.url?
|
|
urlPath = opts.url
|
|
opts.url = "#{settings.apis.olProjects.url}#{urlPath}"
|
|
request opts, callback
|
|
else
|
|
callback(new Errors.ServiceNotConfiguredError('OL Projects service not configured'))
|
|
|
|
module.exports = OlProjectGetter =
|
|
findAllUsersProjects: (userId, callback = (error, projects) ->) ->
|
|
oAuthRequest userId, {
|
|
url: "#{settings.overleaf.host}/api/v1/sharelatex/docs"
|
|
method: 'GET'
|
|
json: true
|
|
}, (error, docs) ->
|
|
return callback(error) if error?
|
|
logger.log {userId, docs}, "got projects from OL"
|
|
callback(null, docs) |