ComunicWeb/assets/js/components/conversations/interface.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-06-07 17:24:48 +00:00
/**
* 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
2017-06-10 07:42:09 +00:00
* * @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
2017-06-07 17:24:48 +00:00
* @param {Function} afterCreate What to do once the conversation is created
* @return {Boolean} True for a success
*/
2017-06-10 07:42:09 +00:00
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;
}
2017-06-07 17:24:48 +00:00
}