mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 13:59:29 +00:00
Improved conversation get methods
This commit is contained in:
parent
eed7db90cf
commit
df1808c6c3
@ -305,7 +305,7 @@ class conversationsController{
|
||||
Rest_fatal_error(401, "Specified user doesn't belongs to the conversation number ".$conversationID." !");
|
||||
|
||||
//Then we can get the ten las messages of the conversation system
|
||||
$conversationsMessages[$conversationID] = CS::get()->components->conversations->getLastMessages($conversationID, 10);
|
||||
$conversationsMessages["conversation-".$conversationID] = CS::get()->components->conversations->getLastMessages($conversationID, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -557,8 +557,29 @@ class conversations {
|
||||
$conversationID
|
||||
);
|
||||
|
||||
//Define required fields
|
||||
$requiredFields = array(
|
||||
"ID",
|
||||
"ID_utilisateurs AS ID_user",
|
||||
"image_path",
|
||||
"message",
|
||||
"time_insert"
|
||||
);
|
||||
|
||||
//Try to perform request on the database
|
||||
$messages = CS::get()->db->select($tableName, $conditions, $condVals);
|
||||
$messages = CS::get()->db->select($tableName, $conditions, $condVals, $requiredFields);
|
||||
|
||||
//Process each message
|
||||
array_walk($messages, function(&$item){
|
||||
//Check if image is not null
|
||||
if($item["image_path"] !== null && $item["image_path"] != ""){
|
||||
//Replace image name with full URL
|
||||
$item["image_path"] = path_user_data($item["image_path"]);
|
||||
}
|
||||
});
|
||||
|
||||
//Revert messages order
|
||||
$messages = array_reverse($messages);
|
||||
|
||||
//Return messages
|
||||
return $messages;
|
||||
|
Loading…
Reference in New Issue
Block a user