2018-12-20 14:14:08 -05:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
|
|
|
max-len,
|
|
|
|
*/
|
|
|
|
// 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
|
|
|
|
*/
|
|
|
|
const request = require("request").defaults({baseUrl: "http://localhost:3010"});
|
2016-12-14 12:38:14 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
module.exports = {
|
|
|
|
sendGlobalMessage(project_id, user_id, content, callback) {
|
|
|
|
return request.post({
|
|
|
|
url: `/project/${project_id}/messages`,
|
|
|
|
json: {
|
|
|
|
user_id,
|
|
|
|
content
|
|
|
|
}
|
|
|
|
}, callback);
|
|
|
|
},
|
2016-12-14 12:38:14 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
getGlobalMessages(project_id, callback) {
|
|
|
|
return request.get({
|
|
|
|
url: `/project/${project_id}/messages`,
|
2016-12-16 11:52:50 -05:00
|
|
|
json: true
|
2018-12-20 14:14:05 -05:00
|
|
|
}, callback);
|
|
|
|
},
|
2016-12-16 11:52:50 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
sendMessage(project_id, thread_id, user_id, content, callback) {
|
|
|
|
return request.post({
|
|
|
|
url: `/project/${project_id}/thread/${thread_id}/messages`,
|
|
|
|
json: {
|
|
|
|
user_id,
|
|
|
|
content
|
|
|
|
}
|
|
|
|
}, callback);
|
|
|
|
},
|
2016-12-16 11:52:50 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
getThreads(project_id, callback) {
|
|
|
|
return request.get({
|
|
|
|
url: `/project/${project_id}/threads`,
|
2016-12-14 12:38:14 -05:00
|
|
|
json: true
|
2018-12-20 14:14:05 -05:00
|
|
|
}, callback);
|
|
|
|
},
|
2017-01-04 08:51:08 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
resolveThread(project_id, thread_id, user_id, callback) {
|
|
|
|
return request.post({
|
|
|
|
url: `/project/${project_id}/thread/${thread_id}/resolve`,
|
2017-01-04 08:51:08 -05:00
|
|
|
json: {
|
2018-12-20 14:14:05 -05:00
|
|
|
user_id
|
2017-01-04 08:51:08 -05:00
|
|
|
}
|
2018-12-20 14:14:05 -05:00
|
|
|
}, callback);
|
|
|
|
},
|
2017-01-04 08:51:08 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
reopenThread(project_id, thread_id, callback) {
|
|
|
|
return request.post({
|
|
|
|
url: `/project/${project_id}/thread/${thread_id}/reopen`,
|
|
|
|
}, callback);
|
|
|
|
},
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
deleteThread(project_id, thread_id, callback) {
|
|
|
|
return request.del({
|
|
|
|
url: `/project/${project_id}/thread/${thread_id}`,
|
|
|
|
}, callback);
|
|
|
|
},
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
editMessage(project_id, thread_id, message_id, content, callback) {
|
|
|
|
return request.post({
|
|
|
|
url: `/project/${project_id}/thread/${thread_id}/messages/${message_id}/edit`,
|
|
|
|
json: {
|
|
|
|
content
|
|
|
|
}
|
|
|
|
}, callback);
|
|
|
|
},
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
deleteMessage(project_id, thread_id, message_id, callback) {
|
|
|
|
return request.del({
|
|
|
|
url: `/project/${project_id}/thread/${thread_id}/messages/${message_id}`,
|
|
|
|
}, callback);
|
|
|
|
}
|
|
|
|
};
|