mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 06:09:12 -05:00
e5676a9643
Revert "Improve GCP logging for web" GitOrigin-RevId: 92d446baf62108da1df92146eec12a2fe69d30ee
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
/* eslint-disable
|
|
node/handle-callback-err,
|
|
max-len,
|
|
no-unused-vars,
|
|
*/
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
// Fix any style issues and re-enable lint.
|
|
/*
|
|
* 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
|
|
*/
|
|
const Settings = require('@overleaf/settings')
|
|
const logger = require('logger-sharelatex')
|
|
const Async = require('async')
|
|
|
|
const UserSessionsRedis = require('../../../../app/src/Features/User/UserSessionsRedis')
|
|
|
|
// rclient = redis.createClient(Settings.redis.web)
|
|
const rclient = UserSessionsRedis.client()
|
|
|
|
module.exports = {
|
|
getUserSessions(user, callback) {
|
|
if (callback == null) {
|
|
callback = function () {}
|
|
}
|
|
return rclient.smembers(
|
|
UserSessionsRedis.sessionSetKey(user),
|
|
(err, result) => callback(err, result)
|
|
)
|
|
},
|
|
|
|
clearUserSessions(user, callback) {
|
|
if (callback == null) {
|
|
callback = function () {}
|
|
}
|
|
const sessionSetKey = UserSessionsRedis.sessionSetKey(user)
|
|
return rclient.smembers(sessionSetKey, (err, sessionKeys) => {
|
|
if (err) {
|
|
return callback(err)
|
|
}
|
|
if (sessionKeys.length === 0) {
|
|
return callback(null)
|
|
}
|
|
const actions = sessionKeys.map(k => cb => rclient.del(k, err => cb(err)))
|
|
return Async.series(actions, (err, results) =>
|
|
rclient.srem(sessionSetKey, sessionKeys, err => {
|
|
if (err) {
|
|
return callback(err)
|
|
}
|
|
return callback(null)
|
|
})
|
|
)
|
|
})
|
|
},
|
|
}
|