overleaf/services/chat/test/acceptance/js/helpers/ChatClient.js

110 lines
2.3 KiB
JavaScript
Raw Normal View History

// 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
*/
const request = require('request').defaults({
2021-07-13 07:04:48 -04:00
baseUrl: 'http://localhost:3010',
})
module.exports = {
sendGlobalMessage(projectId, userId, content, callback) {
return request.post(
{
url: `/project/${projectId}/messages`,
json: {
user_id: userId,
2021-07-13 07:04:48 -04:00
content,
},
},
callback
)
},
getGlobalMessages(projectId, callback) {
return request.get(
{
url: `/project/${projectId}/messages`,
2021-07-13 07:04:48 -04:00
json: true,
},
callback
)
},
sendMessage(projectId, threadId, userId, content, callback) {
return request.post(
{
url: `/project/${projectId}/thread/${threadId}/messages`,
json: {
user_id: userId,
2021-07-13 07:04:48 -04:00
content,
},
},
callback
)
},
getThreads(projectId, callback) {
return request.get(
{
url: `/project/${projectId}/threads`,
2021-07-13 07:04:48 -04:00
json: true,
},
callback
)
},
resolveThread(projectId, threadId, userId, callback) {
return request.post(
{
url: `/project/${projectId}/thread/${threadId}/resolve`,
json: {
user_id: userId,
2021-07-13 07:04:48 -04:00
},
},
callback
)
},
reopenThread(projectId, threadId, callback) {
return request.post(
{
url: `/project/${projectId}/thread/${threadId}/reopen`,
},
callback
)
},
deleteThread(projectId, threadId, callback) {
return request.del(
{
url: `/project/${projectId}/thread/${threadId}`,
},
callback
)
},
editMessage(projectId, threadId, messageId, content, callback) {
return request.post(
{
url: `/project/${projectId}/thread/${threadId}/messages/${messageId}/edit`,
json: {
2021-07-13 07:04:48 -04:00
content,
},
},
callback
)
},
deleteMessage(projectId, threadId, messageId, callback) {
return request.del(
{
url: `/project/${projectId}/thread/${threadId}/messages/${messageId}`,
},
callback
)
2021-07-13 07:04:48 -04:00
},
}