2014-08-15 09:50:36 +00:00
|
|
|
MessageHttpController = require('./Features/Messages/MessageHttpController')
|
2016-12-16 16:52:50 +00:00
|
|
|
{ObjectId} = require "./mongojs"
|
2014-08-15 09:50:36 +00:00
|
|
|
|
|
|
|
module.exports = Router =
|
2016-12-14 17:38:14 +00:00
|
|
|
route: (app) ->
|
2016-12-16 16:52:50 +00:00
|
|
|
app.param 'project_id', (req, res, next, project_id) ->
|
|
|
|
if ObjectId.isValid(project_id)
|
|
|
|
next()
|
|
|
|
else
|
|
|
|
res.send 400, "Invalid project_id"
|
|
|
|
|
|
|
|
app.param 'thread_id', (req, res, next, thread_id) ->
|
|
|
|
if ObjectId.isValid(thread_id)
|
|
|
|
next()
|
|
|
|
else
|
|
|
|
res.send 400, "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
|
2017-01-04 13:51:08 +00:00
|
|
|
|
2017-01-24 14:44:32 +00:00
|
|
|
app.post "/project/:project_id/thread/:thread_id/messages/:message_id/edit", MessageHttpController.editMessage
|
|
|
|
app.del "/project/:project_id/thread/:thread_id/messages/:message_id", MessageHttpController.deleteMessage
|
2017-01-04 13:51:08 +00:00
|
|
|
|
|
|
|
app.post "/project/:project_id/thread/:thread_id/resolve", MessageHttpController.resolveThread
|
|
|
|
app.post "/project/:project_id/thread/:thread_id/reopen", MessageHttpController.reopenThread
|
2017-01-24 14:44:32 +00:00
|
|
|
app.del "/project/:project_id/thread/:thread_id", MessageHttpController.deleteThread
|
2017-01-04 13:51:08 +00:00
|
|
|
|
2014-08-15 09:50:36 +00:00
|
|
|
app.get "/status", (req, res, next) ->
|
|
|
|
res.send("chat is alive")
|
|
|
|
|
|
|
|
|
|
|
|
|