2020-05-06 06:09:15 -04: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 06:08:21 -04: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 06:09:33 -04:00
let HistoryRedisManager
2021-07-12 12:47:15 -04:00
const Settings = require ( '@overleaf/settings' )
2020-11-10 06:32:04 -05:00
const rclient = require ( '@overleaf/redis-wrapper' ) . createClient (
Settings . redis . history
)
2020-05-06 06:09:33 -04:00
const Keys = Settings . redis . history . key _schema
const logger = require ( 'logger-sharelatex' )
2017-04-13 12:00:42 -04:00
2020-05-06 06:09:33 -04: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 ( )
}
)
2021-07-13 07:04:42 -04:00
} ,
2020-05-06 06:09:33 -04:00
}