Follow state of a conversation can be updated

This commit is contained in:
Pierre
2017-06-18 10:07:52 +02:00
parent b1e340e0c1
commit 952779f527
7 changed files with 84 additions and 15 deletions

View File

@ -12,7 +12,7 @@ class conversationsController{
*
* @url POST /conversations/getList
*/
public function getConversationsList(){
public function getList(){
user_login_required();
//Try to get the list
@ -31,7 +31,7 @@ class conversationsController{
*
* @url POST /conversations/getInfosOne
*/
public function getOneConversationInformations(){
public function getOneInformations(){
user_login_required();
//First, check the parametres
@ -62,7 +62,7 @@ class conversationsController{
*
* @url POST /conversations/create
*/
public function createConversation(){
public function create(){
user_login_required();
//Check for parametres
@ -96,4 +96,34 @@ class conversationsController{
);
}
/**
* Update a conversation settings
*
* @url POST /conversations/updateSettings
*/
public function updateSettings(){
user_login_required();
//Check conversation ID was specified
if(!isset($_POST["conversationID"]))
Rest_fatal_error("501", "Please specify a conversation ID !");
$conversationID = toInt($_POST["conversationID"]);
//Check if the user is a conversation moderator or not
if(!CS::get()->components->conversations->userBelongsTo(userID, $conversationID))
Rest_fatal_error("401", "Specified user doesn't belongs to the conversation !");
//Check if user want to update its follow state
if(isset($_POST['following'])){
$follow = $_POST["following"] === "true" ? true : false;
//Try to update follow state
if(!CS::get()->components->conversations->changeFollowState(userID, $conversationID, $follow))
Rest_fatal_error(500, "Couldn't update user follow state !");
}
//Success
return array("success" => "User informations were successfully updated !");
}
}

View File

@ -39,7 +39,7 @@ class friendsController{
Rest_fatal_error(501, "Please check your parametres !");
//Extract informations and process request
$friendID = $_POST['friendID']*1;
$friendID = toInt($_POST['friendID']);
$acceptRequest = $_POST['accept'] == "true";
//Try to perform request

View File

@ -21,7 +21,7 @@ class searchController
Rest_fatal_error(400, "Please specify search terms");
//Check for search limit
$searchLimit = (isset($_POST['searchLimit']) ? $_POST['searchLimit']*1 : 5);
$searchLimit = (isset($_POST['searchLimit']) ? toInt($_POST['searchLimit']) : 5);
//Check the limit
if($searchLimit < 1 || $searchLimit > 25)

View File

@ -72,18 +72,14 @@ class userController
//Determine userID
if(isset($_POST['userID'])){
$usersID = array($_POST['userID']*1);
$usersID = array(toInt($_POST['userID']));
}
elseif(isset($_POST['usersID'])){
//Generate users ID list
$usersID = array();
foreach(explode(",", $_POST['usersID']) as $userID){
if($userID*1 > 0)
$usersID[$userID*1] = $userID*1;
}
$usersID = users_list_to_array($_POST['usersID']);
//Check for errors
if(count($userID) == 0)
if(count($usersID) == 0)
Rest_fatal_error(400, "No user ID were specified!");
}
else