Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/assets/vue/services/message.js

40 lines
1.3 KiB

import makeService from "./api"
import baseService from "./baseService"
import axios from "axios"
// MIGRATION IN PROGRESS. makeService is deprecated
// if you use some method in this service you should try to refactor it with new baseService defining async functions
// like create below. A fully migrated service looks like: assets/vue/services/userService.js.
// BE AWARE that makeService use vuex, so we need to ensure behaviour to be the same as the older service
// When makeService is fully migrated, export by default the const messageService and change imports in all components
// that use this service
export default makeService("messages")
/**
* @param {Object} message
* @returns {Promise<Object>}
*/
async function create(message) {
return await baseService.post("/api/messages", message)
}
async function countUnreadMessages(params) {
const queryParams = new URLSearchParams(params).toString()
return await baseService.get(`/api/messages?${queryParams}`)
}
async function deleteMessageForUser(messageId, userId) {
return await axios.patch(`/api/messages/${messageId}/delete-for-user`,
{ userId: userId },
{
headers: {
'Content-Type': 'application/json'
}
})
}
export const messageService = {
create,
countUnreadMessages,
deleteMessageForUser,
};