mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09:29 +00:00
Updated method
This commit is contained in:
parent
5f68d412d4
commit
47fd14f617
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user