2018-12-20 14:14:08 -05:00
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-12-20 14:14:05 -05:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-12-20 14:14:11 -05:00
|
|
|
const request = require('request').defaults({
|
2021-07-13 07:04:48 -04:00
|
|
|
baseUrl: 'http://localhost:3010',
|
2018-12-20 14:14:11 -05:00
|
|
|
})
|
2016-12-14 12:38:14 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
module.exports = {
|
2022-01-06 11:32:46 -05:00
|
|
|
sendGlobalMessage(projectId, userId, content, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.post(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/messages`,
|
2018-12-20 14:14:11 -05:00
|
|
|
json: {
|
2022-01-06 11:32:46 -05:00
|
|
|
user_id: userId,
|
2021-07-13 07:04:48 -04:00
|
|
|
content,
|
|
|
|
},
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
2016-12-16 11:52:50 -05:00
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
getGlobalMessages(projectId, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.get(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/messages`,
|
2021-07-13 07:04:48 -04:00
|
|
|
json: true,
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
2017-01-04 08:51:08 -05:00
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
sendMessage(projectId, threadId, userId, content, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.post(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/thread/${threadId}/messages`,
|
2018-12-20 14:14:11 -05:00
|
|
|
json: {
|
2022-01-06 11:32:46 -05:00
|
|
|
user_id: userId,
|
2021-07-13 07:04:48 -04:00
|
|
|
content,
|
|
|
|
},
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
getThreads(projectId, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.get(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/threads`,
|
2021-07-13 07:04:48 -04:00
|
|
|
json: true,
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
resolveThread(projectId, threadId, userId, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.post(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/thread/${threadId}/resolve`,
|
2018-12-20 14:14:11 -05:00
|
|
|
json: {
|
2022-01-06 11:32:46 -05:00
|
|
|
user_id: userId,
|
2021-07-13 07:04:48 -04:00
|
|
|
},
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
reopenThread(projectId, threadId, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.post(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/thread/${threadId}/reopen`,
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
deleteThread(projectId, threadId, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.del(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/thread/${threadId}`,
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
editMessage(projectId, threadId, messageId, content, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.post(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/thread/${threadId}/messages/${messageId}/edit`,
|
2018-12-20 14:14:11 -05:00
|
|
|
json: {
|
2021-07-13 07:04:48 -04:00
|
|
|
content,
|
|
|
|
},
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
|
|
|
|
2022-01-06 11:32:46 -05:00
|
|
|
deleteMessage(projectId, threadId, messageId, callback) {
|
2018-12-20 14:14:11 -05:00
|
|
|
return request.del(
|
|
|
|
{
|
2022-01-06 11:32:46 -05:00
|
|
|
url: `/project/${projectId}/thread/${threadId}/messages/${messageId}`,
|
2018-12-20 14:14:11 -05:00
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
2021-07-13 07:04:48 -04:00
|
|
|
},
|
2018-12-20 14:14:11 -05:00
|
|
|
}
|