Use the mongojs based apis to get Project and User information.

This commit is contained in:
Shane Kilkelly 2016-03-18 11:20:33 +00:00
parent de02928454
commit f3db114654

View file

@ -1,8 +1,8 @@
logger = require("logger-sharelatex") logger = require("logger-sharelatex")
request = require("request") request = require("request")
settings = require("settings-sharelatex") settings = require("settings-sharelatex")
Project = require("../../models/Project").Project ProjectGetter = require "../Project/ProjectGetter"
User = require("../../models/User").User UserGetter = require "../User/UserGetter"
DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler') DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
U = require('underscore') U = require('underscore')
Async = require('async') Async = require('async')
@ -32,12 +32,12 @@ module.exports = ReferencesHandler =
return ids return ids
_isFullIndex: (project, callback = (err, result) ->) -> _isFullIndex: (project, callback = (err, result) ->) ->
User.findOne { _id: project.owner_ref }, { features: true }, (err, owner) -> UserGetter.getUser project.owner_ref, { features: true }, (err, owner) ->
return callback(err) if err? return callback(err) if err?
callback(null, owner?.features?.references == true) callback(null, owner?.features?.references == true)
indexAll: (projectId, callback=(err, data)->) -> indexAll: (projectId, callback=(err, data)->) ->
Project.findOne { _id: projectId }, (err, project) -> ProjectGetter.getProject projectId, {rootFolder: true, owner_ref: 1}, (err, project) ->
if err if err
logger.err {err, projectId}, "error finding project" logger.err {err, projectId}, "error finding project"
return callback(err) return callback(err)
@ -46,7 +46,7 @@ module.exports = ReferencesHandler =
ReferencesHandler._doIndexOperation(projectId, project, docIds, callback) ReferencesHandler._doIndexOperation(projectId, project, docIds, callback)
index: (projectId, docIds, callback=(err, data)->) -> index: (projectId, docIds, callback=(err, data)->) ->
Project.findOne { _id: projectId }, (err, project) -> ProjectGetter.getProject projectId, {rootFolder: true, owner_ref: 1}, (err, project) ->
if err if err
logger.err {err, projectId}, "error finding project" logger.err {err, projectId}, "error finding project"
return callback(err) return callback(err)