mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
aa9d6c8dc9
* [misc] decaff cleanup: RoomManager * [misc] decaff cleanup: RedisClientManager * [misc] decaff cleanup: SafeJsonParse * [misc] decaff cleanup: WebApiManager * [misc] decaff cleanup: WebsocketController * [misc] decaff cleanup: WebsocketLoadBalancer * [misc] decaff cleanup: SessionSockets * [misc] decaff cleanup: HttpController * [misc] decaff cleanup: HttpApiController * [misc] decaff cleanup: HealthCheckManager * [misc] decaff cleanup: EventLogger * [misc] decaff cleanup: Errors o-error will eliminate most of it -- when we migrate over. * [misc] decaff cleanup: DrainManager * [misc] decaff cleanup: DocumentUpdaterManager * [misc] decaff cleanup: DocumentUpdaterController: no-unused-vars * [misc] decaff cleanup: DocumentUpdaterController: Array.from * [misc] decaff cleanup: DocumentUpdaterController: implicit return * [misc] decaff cleanup: DocumentUpdaterController: IIFE * [misc] decaff cleanup: DocumentUpdaterController: null checks * [misc] decaff cleanup: DocumentUpdaterController: simpler loops * [misc] decaff cleanup: DocumentUpdaterController: move module name def * [misc] decaff cleanup: ConnectedUsersManager: handle-callback-err * [misc] decaff cleanup: ConnectedUsersManager: implicit returns * [misc] decaff cleanup: ConnectedUsersManager: null checks * [misc] decaff cleanup: ChannelManager: no-unused-vars * [misc] decaff cleanup: ChannelManager: implicit returns * [misc] decaff cleanup: ChannelManager: other cleanup - var -> const - drop variable assignment before return * [misc] decaff cleanup: AuthorizationManager: handle-callback-err Note: This requires a change in WebsocketController to provide a dummy callback. * [misc] decaff cleanup: AuthorizationManager: Array.from * [misc] decaff cleanup: AuthorizationManager: implicit returns * [misc] decaff cleanup: AuthorizationManager: null checks * [misc] decaff cleanup: Router: handle-callback-err * [misc] decaff cleanup: Router: standard/no-callback-literal * [misc] decaff cleanup: Router: Array.from * [misc] decaff cleanup: Router: implicit returns * [misc] decaff cleanup: Router: refactor __guard__ wrapper * [misc] decaff cleanup: Router: null checks And a minor bug fix: user.id -> user._id * [misc] decaff cleanup: Router: move variable declarations to assignments * [misc] decaff cleanup: app: implicit returns * [misc] decaff cleanup: app: __guard__ * [misc] decaff cleanup: app: null checks * [misc] decaff cleanup: app: function definitions * [misc] decaff cleanup: app: drop unused next argument * [misc] decaff cleanup: app: var -> const
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
/* eslint-disable
|
|
camelcase,
|
|
*/
|
|
const WebsocketLoadBalancer = require('./WebsocketLoadBalancer')
|
|
const DrainManager = require('./DrainManager')
|
|
const logger = require('logger-sharelatex')
|
|
|
|
module.exports = {
|
|
sendMessage(req, res) {
|
|
logger.log({ message: req.params.message }, 'sending message')
|
|
if (Array.isArray(req.body)) {
|
|
for (const payload of req.body) {
|
|
WebsocketLoadBalancer.emitToRoom(
|
|
req.params.project_id,
|
|
req.params.message,
|
|
payload
|
|
)
|
|
}
|
|
} else {
|
|
WebsocketLoadBalancer.emitToRoom(
|
|
req.params.project_id,
|
|
req.params.message,
|
|
req.body
|
|
)
|
|
}
|
|
res.send(204)
|
|
},
|
|
|
|
startDrain(req, res) {
|
|
const io = req.app.get('io')
|
|
let rate = req.query.rate || '4'
|
|
rate = parseFloat(rate) || 0
|
|
logger.log({ rate }, 'setting client drain rate')
|
|
DrainManager.startDrain(io, rate)
|
|
res.send(204)
|
|
},
|
|
|
|
disconnectClient(req, res, next) {
|
|
const io = req.app.get('io')
|
|
const { client_id } = req.params
|
|
const client = io.sockets.sockets[client_id]
|
|
|
|
if (!client) {
|
|
logger.info({ client_id }, 'api: client already disconnected')
|
|
res.sendStatus(404)
|
|
return
|
|
}
|
|
logger.warn({ client_id }, 'api: requesting client disconnect')
|
|
client.on('disconnect', () => res.sendStatus(204))
|
|
client.disconnect()
|
|
}
|
|
}
|