Updated method

This commit is contained in:
Pierre 2018-05-09 20:20:23 +02:00
parent 5f68d412d4
commit 47fd14f617

View File

@ -470,19 +470,10 @@ class ConversationsController{
if(!CS::get()->components->conversations->userBelongsTo(userID, $conversationID)) if(!CS::get()->components->conversations->userBelongsTo(userID, $conversationID))
Rest_fatal_error(401, "Specified user doesn't belongs to the conversation number ".$conversationID." !"); Rest_fatal_error(401, "Specified user doesn't belongs to the conversation number ".$conversationID." !");
//Check if user is the owner of the conversation or not //Try to remove the user from the conversation (delete the conversation if the user
$owner = CS::get()->components->conversations->userIsModerator(userID, $conversationID); // is its owner)
if(!components()->conversations->removeUserFromConversation(userID, $conversationID))
if($owner){ Rest_fatal_error(500, "An error occured while trying to delete the conversation!");
//Delete the conversation
if(!CS::get()->components->conversations->delete_conversation($conversationID))
Rest_fatal_error(500, "Couldn't delete the conversation from the server !");
}
else {
//Delete the membership to the conversation
if(!CS::get()->components->conversations->delete_member($conversationID, userID))
Rest_fatal_error(500, "Couldn't delete conversation membership !");
}
//The operation is a success //The operation is a success