2020-05-06 10:09:15 +00:00
/ * e s l i n t - d i s a b l e
camelcase ,
handle - callback - err ,
no - unused - vars ,
* /
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
2020-05-06 10:08:21 +00:00
/ *
* decaffeinate suggestions :
* DS102 : Remove unnecessary code created because of implicit returns
* DS207 : Consider shorter variations of null checks
* Full docs : https : //github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
* /
2020-05-06 10:09:33 +00:00
let HistoryRedisManager
const Settings = require ( 'settings-sharelatex' )
2020-11-10 11:32:04 +00:00
const rclient = require ( '@overleaf/redis-wrapper' ) . createClient (
Settings . redis . history
)
2020-05-06 10:09:33 +00:00
const Keys = Settings . redis . history . key _schema
const logger = require ( 'logger-sharelatex' )
2017-04-13 16:00:42 +00:00
2020-05-06 10:09:33 +00:00
module . exports = HistoryRedisManager = {
recordDocHasHistoryOps ( project _id , doc _id , ops , callback ) {
if ( ops == null ) {
ops = [ ]
}
if ( callback == null ) {
callback = function ( error ) { }
}
if ( ops . length === 0 ) {
return callback ( new Error ( 'cannot push no ops' ) ) // This should never be called with no ops, but protect against a redis error if we sent an empty array to rpush
}
logger . log ( { project _id , doc _id } , 'marking doc in project for history ops' )
return rclient . sadd (
Keys . docsWithHistoryOps ( { project _id } ) ,
doc _id ,
function ( error ) {
if ( error != null ) {
return callback ( error )
}
return callback ( )
}
)
}
}