src/snac/server/ServerExecutor.php
/**
     * Read Message
     *
     * Given a message id on input, read the message and return it to the client, if they
     * have permissions to read it.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACInputException
     * @throws \snac\exceptions\SNACPermissionException
     * @return string[] The response to send to the client
     */
Read Message
Given a message id on input, read the message and return it to the client, if they
have permissions to read it.


Read Message Given a message id on input read the message and return it to the client if they have permissions to read it .
public function readMessage(&$input) {
        if (!isset($input["messageid"])) {
            throw new \snac\exceptions\SNACInputException("No message ID given to read", 400);
        }
        $response = array();
        $message = $this->uStore->getMessageByID($input["messageid"]);
        if ($message === false) {
            throw new \snac\exceptions\SNACInputException("Message does not exist", 404);
        }
        if (($message->getToUser() !== null && $message->getToUser()->getUserID() === $this->user->getUserID()) ||
            ($message->getFromUser() !== null && $message->getFromUser()->getUserID() === $this->user->getUserID())) {
                $response["message"] = $message->toArray();
        } else {
            throw new \snac\exceptions\SNACPermissionException("User does not have permission to read the message.", 403);
        }
        $response["result"] = "success";
        return $response;
    }
public function readMessage ( & $ input ) { if ( ! isset ( $ input [ " messageid " ] ) ) { throw new \ snac \ exceptions \ SNACInputException ( " No message ID given to read " , 400 ) ; } $ response = array ( ) ; $ message = $ this -> uStore -> getMessageByID ( $ input [ " messageid " ] ) ; if ( $ message === false ) { throw new \ snac \ exceptions \ SNACInputException ( " Message does not exist " , 404 ) ; } if ( ( $ message -> getToUser ( ) !== null && $ message -> getToUser ( ) -> getUserID ( ) === $ this -> user -> getUserID ( ) ) || ( $ message -> getFromUser ( ) !== null && $ message -> getFromUser ( ) -> getUserID ( ) === $ this -> user -> getUserID ( ) ) ) { $ response [ " message " ] = $ message -> toArray ( ) ; } else { throw new \ snac \ exceptions \ SNACPermissionException ( " User does not have permission to read the message. " , 403 ) ; } $ response [ " result " ] = " success " ; return $ response ; }
Read Message
 Given a message id on input, read the message and return it to the client, if they
 have permissions to read it.
Read Message Given a message id on input read the message and return it to the client if they have permissions to read it .