diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js b/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js index ab8b4bd9df..70ebb6ae4d 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js @@ -12,12 +12,15 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ let parseParams + const tpdsUpdateHandler = require('./TpdsUpdateHandler') const UpdateMerger = require('./UpdateMerger') const logger = require('logger-sharelatex') const Path = require('path') const metrics = require('metrics-sharelatex') const NotificationsBuilder = require('../Notifications/NotificationsBuilder') +const AuthenticationController = require('../Authentication/AuthenticationController') +const TdpsQueueManager = require('./TpdsQueueManager').promises module.exports = { // mergeUpdate and deleteUpdate are used by Dropbox, where the project is only passed as the name, as the @@ -130,6 +133,16 @@ module.exports = { }) }, + async getQueues(req, res) { + const userId = AuthenticationController.getLoggedInUserId(req) + try { + res.json(await TdpsQueueManager.getQueues(userId)) + } catch (err) { + logger.error({ err, userId }, 'error getting queues') + res.json({ error: 'error getting queues' }) + } + }, + parseParams: (parseParams = function(req) { let filePath, projectName let path = req.params[0] diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsQueueManager.js b/services/web/app/src/Features/ThirdPartyDataStore/TpdsQueueManager.js new file mode 100644 index 0000000000..df079454b1 --- /dev/null +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsQueueManager.js @@ -0,0 +1,15 @@ +const Settings = require('settings-sharelatex') +const request = require('request-promise-native') + +async function getQueues(userId) { + return request({ + uri: `${Settings.apis.tpdsworker.url}/queues/${userId}`, + json: true + }) +} + +module.exports = { + promises: { + getQueues + } +} diff --git a/services/web/app/src/router.js b/services/web/app/src/router.js index 26e8c3a959..7d1ed33553 100644 --- a/services/web/app/src/router.js +++ b/services/web/app/src/router.js @@ -246,6 +246,12 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) { ) // for /user/reconfirm POST, see password router + webRouter.get( + '/user/tpds/queues', + AuthenticationController.requireLogin(), + TpdsController.getQueues + ) + webRouter.get( '/user/projects', AuthenticationController.requireLogin(),