mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-26 10:58:49 +00:00
45 lines
1.1 KiB
JavaScript
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;
|
|
}
|
|
} |