mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 08:35:18 +00:00
Can get older messages of a conversation
This commit is contained in:
@ -600,6 +600,34 @@ class Conversations {
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the older messages of a conversation
|
||||
*
|
||||
* @param int $conversationID The ID of the target conversation
|
||||
* @param int $startID The ID from which the research should start
|
||||
* @param int $limit The maximum number of message to get (positive number)
|
||||
* @return array The list of messages found
|
||||
*/
|
||||
public function getOlderMessages(int $conversationID, int $startID, int $limit) : array {
|
||||
|
||||
//Define conditions
|
||||
$conditions = "WHERE ID_".$this->conversationsListTable." = ? AND ID < ? ORDER BY ID DESC LIMIT ".($limit);
|
||||
$condVals = array(
|
||||
$conversationID,
|
||||
$startID + 1
|
||||
);
|
||||
|
||||
//Perform request
|
||||
$messages = $this->getMessages($conditions, $condVals);
|
||||
|
||||
//Revert messages order
|
||||
$messages = array_reverse($messages);
|
||||
|
||||
//Return messages
|
||||
return $messages;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a conversation exists or not
|
||||
*
|
||||
|
Reference in New Issue
Block a user