mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-27 07:03:05 +00:00
84 lines
2.3 KiB
JavaScript
84 lines
2.3 KiB
JavaScript
/* eslint-disable
|
|
camelcase,
|
|
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
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
*/
|
|
let Router
|
|
const MessageHttpController = require('./Features/Messages/MessageHttpController')
|
|
const { ObjectId } = require('./mongodb')
|
|
|
|
module.exports = Router = {
|
|
route(app) {
|
|
app.param('project_id', function (req, res, next, project_id) {
|
|
if (ObjectId.isValid(project_id)) {
|
|
return next()
|
|
} else {
|
|
return res.status(400).send('Invalid project_id')
|
|
}
|
|
})
|
|
|
|
app.param('thread_id', function (req, res, next, thread_id) {
|
|
if (ObjectId.isValid(thread_id)) {
|
|
return next()
|
|
} else {
|
|
return res.status(400).send('Invalid thread_id')
|
|
}
|
|
})
|
|
|
|
// These are for backwards compatibility
|
|
app.get(
|
|
'/room/:project_id/messages',
|
|
MessageHttpController.getGlobalMessages
|
|
)
|
|
app.post(
|
|
'/room/:project_id/messages',
|
|
MessageHttpController.sendGlobalMessage
|
|
)
|
|
|
|
app.get(
|
|
'/project/:project_id/messages',
|
|
MessageHttpController.getGlobalMessages
|
|
)
|
|
app.post(
|
|
'/project/:project_id/messages',
|
|
MessageHttpController.sendGlobalMessage
|
|
)
|
|
|
|
app.post(
|
|
'/project/:project_id/thread/:thread_id/messages',
|
|
MessageHttpController.sendThreadMessage
|
|
)
|
|
app.get('/project/:project_id/threads', MessageHttpController.getAllThreads)
|
|
|
|
app.post(
|
|
'/project/:project_id/thread/:thread_id/messages/:message_id/edit',
|
|
MessageHttpController.editMessage
|
|
)
|
|
app.delete(
|
|
'/project/:project_id/thread/:thread_id/messages/:message_id',
|
|
MessageHttpController.deleteMessage
|
|
)
|
|
|
|
app.post(
|
|
'/project/:project_id/thread/:thread_id/resolve',
|
|
MessageHttpController.resolveThread
|
|
)
|
|
app.post(
|
|
'/project/:project_id/thread/:thread_id/reopen',
|
|
MessageHttpController.reopenThread
|
|
)
|
|
app.delete(
|
|
'/project/:project_id/thread/:thread_id',
|
|
MessageHttpController.deleteThread
|
|
)
|
|
|
|
return app.get('/status', (req, res, next) => res.send('chat is alive'))
|
|
},
|
|
}
|