Chatwoot/app/javascript/dashboard/api/inbox/message.js
Pranav Raj S 0f2d3418f9
fix: Add a check for 24 hour window before sending a message (#1084)
Co-authored-by: Sojan Jose <sojan@pepalo.com>
2020-07-25 22:54:45 +05:30

35 lines
908 B
JavaScript

/* eslint no-console: 0 */
/* global axios */
import ApiClient from '../ApiClient';
class MessageApi extends ApiClient {
constructor() {
super('conversations', { accountScoped: true });
}
create({ conversationId, message, private: isPrivate }) {
return axios.post(`${this.url}/${conversationId}/messages`, {
content: message,
private: isPrivate,
});
}
getPreviousMessages({ conversationId, before }) {
return axios.get(`${this.url}/${conversationId}/messages`, {
params: { before },
});
}
sendAttachment([conversationId, { file, isPrivate = false }]) {
const formData = new FormData();
formData.append('attachments[]', file, file.name);
formData.append('private', isPrivate);
return axios({
method: 'post',
url: `${this.url}/${conversationId}/messages`,
data: formData,
});
}
}
export default new MessageApi();