mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Can get the number of unread conversations of a user
This commit is contained in:
parent
3a3c6d9787
commit
2f37d37a54
@ -386,6 +386,22 @@ class conversationsController{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of unread conversations of the user
|
||||
*
|
||||
* @url POST conversations/get_number_unread
|
||||
*/
|
||||
public function get_number_unread(){
|
||||
|
||||
user_login_required();
|
||||
|
||||
//Get the number of unread conversations of the user
|
||||
$number_unread_conversations = components()->conversations->number_user_unread(userID);
|
||||
|
||||
//Return result
|
||||
return array("nb_unread" => $number_unread_conversations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a conversation
|
||||
*
|
||||
|
@ -766,6 +766,24 @@ class conversations {
|
||||
return CS::get()->db->deleteEntry($this->conversationsListTable, "ID = ?", array($convID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of unread conversations of a user
|
||||
*
|
||||
* @param int $userID Target user ID
|
||||
* @return int The number of unread conversations of the user
|
||||
*/
|
||||
public function number_user_unread(int $userID) : int {
|
||||
|
||||
//Prepare database request
|
||||
$tableName = $this->conversationsUsersTable;
|
||||
$conditions = "WHERE ID_utilisateurs = ? AND saw_last_message = 0";
|
||||
$values = array($userID);
|
||||
|
||||
//Perform request and return result
|
||||
return CS::get()->db->count($tableName, $conditions, $values);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of conversation messages based on specified conditions
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user