ComunicWeb/assets/js/components/conversations/interface.js
2017-06-10 09:42:09 +02:00

45 lines
1.1 KiB
JavaScript

/**
* Interface between the graphical conversation system and the API
*
* @author Pierre HUBERT
*/
ComunicWeb.components.conversations.interface = {
/**
* Create a conversation
*
* @param {Object} infos Informations about the conversation to create
* * @info {Array} users A list of the members of the conversation
* * @info {Boolan} follow Defines if the current user wants to follow the conversation or not
* * @info {Mixed} conversationName The name of the conversation
* @param {Function} afterCreate What to do once the conversation is created
* @return {Boolean} True for a success
*/
createConversation: function(infos, afterCreate){
//Prepare an API request
var apiURI = "conversations/create";
var params = {
name: infos.conversationName,
follow : infos.follow,
users: infos.users,
};
//Perform the API request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
//Check for errors
if(result.error){
//Log error
ComunicWeb.debug.logMessage("ERROR ! Couldn't create a conversation!");
}
//Perform next action
afterCreate(result);
});
//Success
return true;
}
}