mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Move functions to prepare for async/await
GitOrigin-RevId: b0f43d14a214d1f7695b3b312d63827d2c82470c
This commit is contained in:
parent
50723d0f8f
commit
696bfa3756
1 changed files with 105 additions and 101 deletions
|
@ -46,32 +46,7 @@ const { plainTextResponse } = require('../../infrastructure/Response')
|
|||
const ReferencesHandler = require('../References/ReferencesHandler')
|
||||
const EditorRealTimeController = require('../Editor/EditorRealTimeController')
|
||||
|
||||
module.exports = LinkedFilesController = {
|
||||
Agents: _.extend(
|
||||
{
|
||||
url: require('./UrlAgent'),
|
||||
project_file: require('./ProjectFileAgent'),
|
||||
project_output_file: require('./ProjectOutputFileAgent'),
|
||||
},
|
||||
Modules.linkedFileAgentsIncludes()
|
||||
),
|
||||
|
||||
_getAgent(provider) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(
|
||||
LinkedFilesController.Agents,
|
||||
provider
|
||||
)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
if (!Array.from(Settings.enabledLinkedFileTypes).includes(provider)) {
|
||||
return null
|
||||
}
|
||||
return LinkedFilesController.Agents[provider]
|
||||
},
|
||||
|
||||
createLinkedFile(req, res, next) {
|
||||
function createLinkedFile(req, res, next) {
|
||||
const { project_id: projectId } = req.params
|
||||
const { name, provider, data, parent_folder_id: parentFolderId } = req.body
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
|
@ -106,9 +81,9 @@ module.exports = LinkedFilesController = {
|
|||
return res.json({ new_file_id: newFileId })
|
||||
}
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
refreshLinkedFile(req, res, next) {
|
||||
function refreshLinkedFile(req, res, next) {
|
||||
const { project_id: projectId, file_id: fileId } = req.params
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
|
||||
|
@ -172,7 +147,36 @@ module.exports = LinkedFilesController = {
|
|||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = LinkedFilesController = {
|
||||
Agents: _.extend(
|
||||
{
|
||||
url: require('./UrlAgent'),
|
||||
project_file: require('./ProjectFileAgent'),
|
||||
project_output_file: require('./ProjectOutputFileAgent'),
|
||||
},
|
||||
Modules.linkedFileAgentsIncludes()
|
||||
),
|
||||
|
||||
_getAgent(provider) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(
|
||||
LinkedFilesController.Agents,
|
||||
provider
|
||||
)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
if (!Array.from(Settings.enabledLinkedFileTypes).includes(provider)) {
|
||||
return null
|
||||
}
|
||||
return LinkedFilesController.Agents[provider]
|
||||
},
|
||||
|
||||
createLinkedFile,
|
||||
|
||||
refreshLinkedFile,
|
||||
|
||||
handleError(error, req, res, next) {
|
||||
if (error instanceof AccessDeniedError) {
|
||||
|
|
Loading…
Reference in a new issue