mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 04:11:01 +00:00
36 lines
1.2 KiB
CoffeeScript
36 lines
1.2 KiB
CoffeeScript
ProjectLocator = require "../Project/ProjectLocator"
|
|
ProjectEntityHandler = require "../Project/ProjectEntityHandler"
|
|
Errors = require "../../errors"
|
|
logger = require("logger-sharelatex")
|
|
|
|
module.exports =
|
|
|
|
getDocument: (req, res, next = (error) ->) ->
|
|
project_id = req.params.Project_id
|
|
doc_id = req.params.doc_id
|
|
logger.log doc_id:doc_id, project_id:project_id, "receiving get document request from api (docupdater)"
|
|
ProjectLocator.findElement project_id: project_id, element_id: doc_id, type: "doc", (error, doc) ->
|
|
if error?
|
|
logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument"
|
|
return next(error)
|
|
res.type "json"
|
|
res.send JSON.stringify {
|
|
lines: doc.lines
|
|
}
|
|
req.session.destroy()
|
|
|
|
|
|
setDocument: (req, res, next = (error) ->) ->
|
|
project_id = req.params.Project_id
|
|
doc_id = req.params.doc_id
|
|
lines = req.body.lines
|
|
logger.log doc_id:doc_id, project_id:project_id, "receiving set document request from api (docupdater)"
|
|
ProjectEntityHandler.updateDocLines project_id, doc_id, lines, (error) ->
|
|
if error?
|
|
logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument"
|
|
return next(error)
|
|
res.send 200
|
|
req.session.destroy()
|
|
|
|
|
|
|