mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Can delete all the conversations of a user
This commit is contained in:
parent
a63056fb95
commit
5f68d412d4
@ -643,6 +643,29 @@ class Conversations {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a user from a conversation
|
||||||
|
*
|
||||||
|
* @param int $userID The ID of the target user
|
||||||
|
* @param int $conversationID The ID of the target conversation
|
||||||
|
* @return bool TRUE for a success / FALSE else
|
||||||
|
*/
|
||||||
|
public function removeUserFromConversation(int $userID, int $conversationID) : bool {
|
||||||
|
|
||||||
|
//Check if user is the owner of the conversation or not
|
||||||
|
$owner = $this->userIsModerator($userID, $conversationID);
|
||||||
|
|
||||||
|
if($owner){
|
||||||
|
//Delete the conversation
|
||||||
|
return $this->delete_conversation($conversationID);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Delete the membership to the conversation
|
||||||
|
return $this->delete_member($conversationID, $userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a conversation
|
* Delete a conversation
|
||||||
*
|
*
|
||||||
@ -851,6 +874,30 @@ class Conversations {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all the conversations of a user
|
||||||
|
*
|
||||||
|
* @param int $userID The target user ID
|
||||||
|
* @return bool TRUE for a success / FALSE else
|
||||||
|
*/
|
||||||
|
public function deleteAllUserConversations(int $userID) : bool {
|
||||||
|
|
||||||
|
//Get the entire list of conversations of the user
|
||||||
|
$list = $this->getList($userID);
|
||||||
|
|
||||||
|
//Process the list of conversations
|
||||||
|
foreach($list as $conversation){
|
||||||
|
|
||||||
|
//Remove the user from the conversation
|
||||||
|
if(!$this->removeUserFromConversation($userID, $conversation->get_id()))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Success
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of conversation messages based on specified conditions
|
* Get a list of conversation messages based on specified conditions
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user