2014-02-12 10:23:40 +00:00
|
|
|
#this file is being slowly refactored out
|
|
|
|
|
|
|
|
logger = require('logger-sharelatex')
|
2014-03-31 15:46:28 +00:00
|
|
|
sanitize = require('sanitizer')
|
2014-02-12 10:23:40 +00:00
|
|
|
projectHandler = require('../handlers/ProjectHandler')
|
|
|
|
projectHandler = new projectHandler()
|
|
|
|
SecurityManager = require('./SecurityManager')
|
|
|
|
_ = require('underscore')
|
|
|
|
projectEditorHandler = require('../Features/Project/ProjectEditorHandler')
|
|
|
|
projectEntityHandler = require('../Features/Project/ProjectEntityHandler')
|
|
|
|
versioningApiHandler = require('../Features/Versioning/VersioningApiHandler')
|
|
|
|
metrics = require('../infrastructure/Metrics')
|
|
|
|
EditorRealTimeController = require('../Features/Editor/EditorRealTimeController')
|
|
|
|
|
|
|
|
module.exports = class CollaberationManager
|
|
|
|
constructor: (@io)->
|
|
|
|
|
2014-04-04 15:53:59 +00:00
|
|
|
|
2014-02-12 10:23:40 +00:00
|
|
|
|
|
|
|
distributMessage: (project_id, client, message)->
|
2014-03-31 15:46:28 +00:00
|
|
|
message = sanitize.escape(message)
|
2014-02-12 10:23:40 +00:00
|
|
|
metrics.inc "editor.instant-message"
|
|
|
|
client.get "first_name", (err, first_name)=>
|
|
|
|
EditorRealTimeController.emitToRoom project_id, 'reciveNewMessage', first_name, message
|
|
|
|
|
|
|
|
setRootDoc: (project_id, newRootDocID, callback)->
|
|
|
|
projectEntityHandler.setRootDoc project_id, newRootDocID, () =>
|
|
|
|
EditorRealTimeController.emitToRoom project_id, 'rootDocUpdated', newRootDocID
|
|
|
|
callback?()
|
|
|
|
|
|
|
|
takeVersionSnapShot : (project_id, message, callback)->
|
|
|
|
versioningApiHandler.takeVersionSnapshot project_id, message, callback
|