mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Conversation members are returned with conversations list
This commit is contained in:
parent
040750d11c
commit
b4de521174
@ -72,7 +72,10 @@ class conversations {
|
|||||||
"last_active" => $processConversation["last_active"],
|
"last_active" => $processConversation["last_active"],
|
||||||
"name" => ($processConversation["name"] == "" ? false : $processConversation["name"]),
|
"name" => ($processConversation["name"] == "" ? false : $processConversation["name"]),
|
||||||
"following" => $processConversation["following"],
|
"following" => $processConversation["following"],
|
||||||
"saw_last_message" => $processConversation["saw_last_message"]
|
"saw_last_message" => $processConversation["saw_last_message"],
|
||||||
|
|
||||||
|
//Get and add conversation members
|
||||||
|
"conversation_members" => $this->getConversationMembers($processConversation["ID"]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +83,36 @@ class conversations {
|
|||||||
return $conversationsList;
|
return $conversationsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a conversation members
|
||||||
|
*
|
||||||
|
* @param Integer $conversationID The ID of the conversation
|
||||||
|
* @return Array A list of the conversation members (empty arary may means that an error occured)
|
||||||
|
*/
|
||||||
|
public function getConversationMembers($conversationID) : array {
|
||||||
|
|
||||||
|
//Perform a request on the database
|
||||||
|
$tableName = $this->conversationUsersTable;
|
||||||
|
$conditions = "WHERE ID_".$this->conversationListTable." = ?";
|
||||||
|
$conditionsValues = array($conversationID*1);
|
||||||
|
$getFields = array("ID_utilisateurs as userID");
|
||||||
|
|
||||||
|
//Perform the request
|
||||||
|
$results = CS::get()->db->select($tableName, $conditions, $conditionsValues, $getFields);
|
||||||
|
|
||||||
|
if($results === false)
|
||||||
|
return array(); //An error occured
|
||||||
|
|
||||||
|
//Process results
|
||||||
|
$membersList = array();
|
||||||
|
|
||||||
|
foreach($results as $processUser)
|
||||||
|
$membersList[] = $processUser["userID"];
|
||||||
|
|
||||||
|
//Return result
|
||||||
|
return $membersList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new conversation
|
* Create a new conversation
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user