* Update chat.scss --skip-ci * Fix height issue * Add highlighting * Implement bannged user handling for chat * Add scroll obsever * Limit initial messages load count & max messages * Add new message alert when scrolled * Add link to usernames in chat * Implement channel clearing feature * Update parserOptions * Implement banning feature for chat app WIP * Add policy for ChatChannelsController * Fix arugment error * Update user_not_authorized to handle JSON request * Update specs for updated user_not_authorized * Update font-weight for windows os
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
export function getAllMessages(successCb, failureCb) {
|
|
fetch('/chat_channels/1', {
|
|
Accept: 'application/json',
|
|
'Content-Type': 'application/json',
|
|
})
|
|
.then(response => response.json())
|
|
.then(successCb)
|
|
.catch(failureCb);
|
|
}
|
|
|
|
export function sendMessage(message, successCb, failureCb) {
|
|
fetch('/messages', {
|
|
method: 'POST',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
'X-CSRF-Token': window.csrfToken,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
message: {
|
|
message_html: message,
|
|
user_id: window.currentUser.id,
|
|
chat_channel_id: '1',
|
|
},
|
|
}),
|
|
credentials: 'same-origin',
|
|
})
|
|
.then(response => response.json())
|
|
.then(successCb)
|
|
.catch(failureCb);
|
|
}
|
|
|
|
export function conductModeration(message, successCb, failureCb) {
|
|
fetch('/chat_channels/1/moderate', {
|
|
method: 'POST',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
'X-CSRF-Token': window.csrfToken,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
chat_channel: {
|
|
command: message,
|
|
},
|
|
}),
|
|
credentials: 'same-origin',
|
|
})
|
|
.then(response => response.json())
|
|
.then(successCb)
|
|
.catch(failureCb);
|
|
}
|