2014-03-10 16:58:26 +00:00
|
|
|
DocumentUpdaterManager = require "./DocumentUpdaterManager"
|
|
|
|
DiffManager = require "./DiffManager"
|
|
|
|
logger = require "logger-sharelatex"
|
|
|
|
|
|
|
|
module.exports = RestoreManager =
|
2014-03-11 13:01:07 +00:00
|
|
|
restoreToBeforeVersion: (project_id, doc_id, version, user_id, callback = (error) ->) ->
|
|
|
|
logger.log project_id: project_id, doc_id: doc_id, version: version, user_id: user_id, "restoring document"
|
2014-03-10 16:58:26 +00:00
|
|
|
DiffManager.getDocumentBeforeVersion project_id, doc_id, version, (error, content) ->
|
|
|
|
return callback(error) if error?
|
2014-03-11 13:01:07 +00:00
|
|
|
DocumentUpdaterManager.setDocument project_id, doc_id, content, user_id, (error) ->
|
2014-03-10 16:58:26 +00:00
|
|
|
return callback(error) if error?
|
|
|
|
callback()
|