mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 20:59:49 -05:00
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
/*
|
|
* 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
|
|
*/
|
|
let HistoryRedisManager;
|
|
const Settings = require('settings-sharelatex');
|
|
const rclient = require("redis-sharelatex").createClient(Settings.redis.history);
|
|
const Keys = Settings.redis.history.key_schema;
|
|
const logger = require('logger-sharelatex');
|
|
|
|
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();
|
|
});
|
|
}
|
|
});
|