]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Fix PHPDoc comments project-wide
[friendica.git] / src / Protocol / Diaspora.php
index ed583503411799c6b0735d1fd85d21148fed1029..0087ced4b1644317dad3b4a4a1bcd8e2661beb23 100644 (file)
@@ -53,6 +53,7 @@ class Diaspora
         * @param array   $contacts The previously fetched contacts
         *
         * @return array of relay servers
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function relayList($item_id, array $contacts = [])
        {
@@ -138,6 +139,7 @@ class Diaspora
         *
         * @param string $server_url The url of the server
         * @return array with the contact
+        * @throws \Exception
         */
        private static function getRelayContact($server_url)
        {
@@ -169,8 +171,9 @@ class Diaspora
        /**
         * @brief Update or insert a relay contact
         *
-        * @param string $server_url The url of the server
-        * @param array $network_fields Optional network specific fields
+        * @param string $server_url     The url of the server
+        * @param array  $network_fields Optional network specific fields
+        * @throws \Exception
         */
        public static function setRelayContact($server_url, array $network_fields = [])
        {
@@ -204,6 +207,7 @@ class Diaspora
         * @param array   $contacts The previously fetched contacts
         *
         * @return array of relay servers
+        * @throws \Exception
         */
        public static function participantsForThread($thread, array $contacts)
        {
@@ -250,6 +254,7 @@ class Diaspora
         * @param integer $level     This value is only set inside this function to avoid endless loops
         *
         * @return string the repaired signature
+        * @throws \Exception
         */
        private static function repairSignature($signature, $handle = "", $level = 1)
        {
@@ -276,6 +281,8 @@ class Diaspora
         * @param string $envelope The magic envelope
         *
         * @return string verified data
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function verifyMagicEnvelope($envelope)
        {
@@ -372,6 +379,8 @@ class Diaspora
         * 'message' -> decoded Diaspora XML message
         * 'author' -> author diaspora handle
         * 'key' -> author public key (converted to pkcs#8)
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function decodeRaw(array $importer, $raw, $no_exit = false)
        {
@@ -475,6 +484,8 @@ class Diaspora
         * 'message' -> decoded Diaspora XML message
         * 'author' -> author diaspora handle
         * 'key' -> author public key (converted to pkcs#8)
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function decode(array $importer, $xml)
        {
@@ -612,6 +623,8 @@ class Diaspora
         * @param array $msg The post that will be dispatched
         *
         * @return int The message id of the generated message, "true" or "false" if there was an error
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function dispatchPublic($msg)
        {
@@ -640,6 +653,8 @@ class Diaspora
         * @param object $fields   SimpleXML object that contains the message
         *
         * @return int The message id of the generated message, "true" or "false" if there was an error
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function dispatch(array $importer, $msg, $fields = null)
        {
@@ -746,6 +761,8 @@ class Diaspora
         * @param array $msg Array with the XML, the sender handle and the sender signature
         *
         * @return bool|array If the posting is valid then an array with an SimpleXML object is returned
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function validPosting($msg)
        {
@@ -894,6 +911,8 @@ class Diaspora
         * @param string $handle The handle
         *
         * @return string The public key
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function key($handle)
        {
@@ -915,6 +934,8 @@ class Diaspora
         * @param string $handle The handle
         *
         * @return array the queried data
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function personByHandle($handle)
        {
@@ -960,6 +981,7 @@ class Diaspora
         * @brief Updates the fcontact table
         *
         * @param array $arr The fcontact data
+        * @throws \Exception
         */
        private static function updateFContact($arr)
        {
@@ -983,6 +1005,7 @@ class Diaspora
         * @param int $pcontact_id The id in the contact table (Used for the public contact)
         *
         * @return string the handle
+        * @throws \Exception
         */
        private static function handleFromContact($contact_id, $pcontact_id = 0)
        {
@@ -1029,6 +1052,7 @@ class Diaspora
         * @param mixed $fcontact_guid Hexadecimal string guid
         *
         * @return string the contact url or null
+        * @throws \Exception
         */
        public static function urlFromContactGuid($fcontact_guid)
        {
@@ -1050,12 +1074,14 @@ class Diaspora
        /**
         * @brief Get a contact id for a given handle
         *
-        * @todo Move to Friendica\Model\Contact
+        * @todo  Move to Friendica\Model\Contact
         *
         * @param int    $uid    The user id
         * @param string $handle The handle in the format user@domain.tld
         *
         * @return int Contact id
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function contactByHandle($uid, $handle)
        {
@@ -1139,6 +1165,7 @@ class Diaspora
         * @param bool   $is_comment Is the check for a comment?
         *
         * @return array The contact data
+        * @throws \Exception
         */
        private static function allowedContactByHandle(array $importer, $handle, $is_comment = false)
        {
@@ -1169,6 +1196,7 @@ class Diaspora
         * @param string $guid The guid of the message
         *
         * @return int|bool message id if the message already was stored into the system - or false.
+        * @throws \Exception
         */
        private static function messageExists($uid, $guid)
        {
@@ -1249,6 +1277,8 @@ class Diaspora
         * @param array $match array containing a link that has to be checked for a message link
         * @param array $item  The item array
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function fetchGuidSub($match, $item)
        {
@@ -1265,6 +1295,8 @@ class Diaspora
         * @param int    $uid    The user id of the user
         *
         * @return int the message id of the stored message or false
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function storeByGuid($guid, $server, $uid = 0)
        {
@@ -1301,6 +1333,7 @@ class Diaspora
         *      'message' => The message XML
         *      'author' => The author handle
         *      'key' => The public key of the author
+        * @throws \Exception
         */
        private static function message($guid, $server, $level = 0)
        {
@@ -1377,6 +1410,7 @@ class Diaspora
         * @param array  $contact The contact of the item owner
         *
         * @return array the item record
+        * @throws \Exception
         */
        private static function parentItem($uid, $guid, $author, array $contact)
        {
@@ -1421,6 +1455,7 @@ class Diaspora
         * @return array
         *      'cid' => contact id
         *      'network' => network type
+        * @throws \Exception
         */
        private static function authorContactByUrl($def_contact, $person, $uid)
        {
@@ -1457,6 +1492,8 @@ class Diaspora
         * @param string $parent_guid optional parent guid
         *
         * @return string the post link
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function plink($addr, $guid, $parent_guid = '')
        {
@@ -1493,6 +1530,8 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool Success
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveAccountMigration(array $importer, $data)
        {
@@ -1550,9 +1589,10 @@ class Diaspora
        /**
         * @brief Processes an account deletion
         *
-        * @param object $data     The message object
+        * @param object $data The message object
         *
         * @return bool Success
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function receiveAccountDeletion($data)
        {
@@ -1578,6 +1618,8 @@ class Diaspora
         * @param boolean $onlyfound Only return uri when found in the database
         *
         * @return string The constructed uri or the one from our database
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function getUriFromGuid($author, $guid, $onlyfound = false)
        {
@@ -1604,6 +1646,7 @@ class Diaspora
         * @param string $uid Author handle
         *
         * @return string The post guid
+        * @throws \Exception
         */
        private static function getGuidFromUri($uri, $uid)
        {
@@ -1621,6 +1664,7 @@ class Diaspora
         * @param string $guid The guid of the item
         *
         * @return array|boolean the origin owner of that post - or false
+        * @throws \Exception
         */
        private static function importerForGuid($guid)
        {
@@ -1644,6 +1688,8 @@ class Diaspora
         * @param string $xml      The original XML of the message
         *
         * @return int The message id of the generated comment or "false" if there was an error
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveComment(array $importer, $sender, $data, $xml)
        {
@@ -1761,6 +1807,7 @@ class Diaspora
         * @param array  $conversation The conversation record to which this message belongs
         *
         * @return bool "true" if it was successful
+        * @throws \Exception
         */
        private static function receiveConversationMessage(array $importer, array $contact, $data, $msg, $mesg, $conversation)
        {
@@ -1850,6 +1897,7 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool Success
+        * @throws \Exception
         */
        private static function receiveConversation(array $importer, $msg, $data)
        {
@@ -1908,6 +1956,8 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return int The message id of the generated like or "false" if there was an error
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveLike(array $importer, $sender, $data)
        {
@@ -2017,6 +2067,7 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool Success?
+        * @throws \Exception
         */
        private static function receiveMessage(array $importer, $data)
        {
@@ -2109,6 +2160,8 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool always true
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveParticipation(array $importer, $data)
        {
@@ -2202,6 +2255,8 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool Success
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveProfile(array $importer, $data)
        {
@@ -2295,6 +2350,7 @@ class Diaspora
         * @param array $importer Array of the importer user
         * @param array $contact  The contact that send the request
         * @return void
+        * @throws \Exception
         */
        private static function receiveRequestMakeFriend(array $importer, array $contact)
        {
@@ -2316,6 +2372,7 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool Success
+        * @throws \Exception
         */
        private static function receiveContactRequest(array $importer, $data)
        {
@@ -2496,9 +2553,9 @@ class Diaspora
         *
         * @param string $guid        message guid
         * @param string $orig_author handle of the original post
-        * @param string $author      handle of the sharer
-        *
         * @return array The fetched item
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function originalItem($guid, $orig_author)
        {
@@ -2579,6 +2636,8 @@ class Diaspora
         * @param string $xml      The original XML of the message
         *
         * @return int the message id
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveReshare(array $importer, $data, $xml)
        {
@@ -2671,6 +2730,7 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool success
+        * @throws \Exception
         */
        private static function itemRetraction(array $importer, array $contact, $data)
        {
@@ -2735,6 +2795,7 @@ class Diaspora
         * @param object $data     The message object
         *
         * @return bool Success
+        * @throws \Exception
         */
        private static function receiveRetraction(array $importer, $sender, $data)
        {
@@ -2775,11 +2836,13 @@ class Diaspora
        /**
         * @brief Receives status messages
         *
-        * @param array  $importer Array of the importer user
-        * @param object $data     The message object
-        * @param string $xml      The original XML of the message
+        * @param array            $importer Array of the importer user
+        * @param SimpleXMLElement $data     The message object
+        * @param string           $xml      The original XML of the message
         *
         * @return int The message id of the newly created item
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function receiveStatusMessage(array $importer, SimpleXMLElement $data, $xml)
        {
@@ -2900,6 +2963,7 @@ class Diaspora
         * @param array $contact contact array
         *
         * @return string the handle in the format user@domain.tld
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function myHandle(array $contact)
        {
@@ -2929,6 +2993,7 @@ class Diaspora
         * @param string $pubkey  The public key of the receiver
         *
         * @return string The encrypted data
+        * @throws \Exception
         */
        public static function encodePrivateData($msg, array $user, array $contact, $prvkey, $pubkey)
        {
@@ -2967,6 +3032,7 @@ class Diaspora
         * @param array  $user The record of the sender
         *
         * @return string The envelope
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function buildMagicEnvelope($msg, array $user)
        {
@@ -3010,6 +3076,7 @@ class Diaspora
         * @param bool   $public  Is the message public?
         *
         * @return string The message that will be transmitted to other servers
+        * @throws \Exception
         */
        public static function buildMessage($msg, array $user, array $contact, $prvkey, $pubkey, $public = false)
        {
@@ -3053,7 +3120,10 @@ class Diaspora
         * @param bool   $queue_run    Is the transmission called from the queue?
         * @param string $guid         message guid
         *
+        * @param bool   $no_queue
         * @return int Result of the transmission
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function transmit(array $owner, array $contact, $envelope, $public_batch, $queue_run = false, $guid = "", $no_queue = false)
        {
@@ -3145,6 +3215,8 @@ class Diaspora
         * @param bool   $spool        Should the transmission be spooled or transmitted?
         *
         * @return int Result of the transmission
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        private static function buildAndTransmit(array $owner, array $contact, $type, $message, $public_batch = false, $guid = "", $spool = false)
        {
@@ -3176,9 +3248,10 @@ class Diaspora
         * @brief sends a participation (Used to get all further updates)
         *
         * @param array $contact Target of the communication
-        * @param array $item    Item array
+        * @param array $item    Item array
         *
         * @return int The result of the transmission
+        * @throws \Exception
         */
        private static function sendParticipation(array $contact, array $item)
        {
@@ -3225,9 +3298,11 @@ class Diaspora
         *
         * @param array $owner   the array of the item owner
         * @param array $contact Target of the communication
-        * @param int   $uid     User ID
+        * @param int   $uid     User ID
         *
         * @return int The result of the transmission
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function sendAccountMigration(array $owner, array $contact, $uid)
        {
@@ -3253,6 +3328,7 @@ class Diaspora
         * @param array $contact Target of the communication
         *
         * @return int The result of the transmission
+        * @throws \Exception
         */
        public static function sendShare(array $owner, array $contact)
        {
@@ -3296,6 +3372,7 @@ class Diaspora
         * @param array $contact Target of the communication
         *
         * @return int The result of the transmission
+        * @throws \Exception
         */
        public static function sendUnshare(array $owner, array $contact)
        {
@@ -3316,6 +3393,8 @@ class Diaspora
         * @param bool   $complete Should it be a complete check or a simple check?
         *
         * @return array|bool Reshare details or "false" if no reshare
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function isReshare($body, $complete = true)
        {
@@ -3403,6 +3482,7 @@ class Diaspora
         * @param integer $event_id The id of the event
         *
         * @return array with event data
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function buildEvent($event_id)
        {
@@ -3485,6 +3565,8 @@ class Diaspora
         * @return array
         * 'type' -> Message type ("status_message" or "reshare")
         * 'message' -> Array of XML elements of the status
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function buildStatus(array $item, array $owner)
        {
@@ -3599,6 +3681,8 @@ class Diaspora
         * @param bool  $public_batch Is it a public post?
         *
         * @return int The result of the transmission
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function sendStatus(array $item, array $owner, array $contact, $public_batch = false)
        {
@@ -3614,6 +3698,7 @@ class Diaspora
         * @param array $owner the array of the item owner
         *
         * @return array The data for a "like"
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function constructLike(array $item, array $owner)
        {
@@ -3645,6 +3730,7 @@ class Diaspora
         * @param array $owner the array of the item owner
         *
         * @return array The data for an "EventParticipation"
+        * @throws \Exception
         */
        private static function constructAttend(array $item, array $owner)
        {
@@ -3682,6 +3768,7 @@ class Diaspora
         * @param array $owner the array of the item owner
         *
         * @return array The data for a comment
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function constructComment(array $item, array $owner)
        {
@@ -3726,6 +3813,8 @@ class Diaspora
         * @param bool  $public_batch Is it a public post?
         *
         * @return int The result of the transmission
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function sendFollowup(array $item, array $owner, array $contact, $public_batch = false)
        {
@@ -3752,10 +3841,8 @@ class Diaspora
        /**
         * @brief Creates a message from a signature record entry
         *
-        * @param array $item      The item that will be exported
-        * @param array $signature The entry of the "sign" record
-        *
-        * @return string The message
+        * @param array $item The item that will be exported
+        * @return array The message
         */
        private static function messageFromSignature(array $item)
        {
@@ -3806,6 +3893,7 @@ class Diaspora
         * @param bool  $public_batch Is it a public post?
         *
         * @return int The result of the transmission
+        * @throws \Exception
         */
        public static function sendRelay(array $item, array $owner, array $contact, $public_batch = false)
        {
@@ -3862,6 +3950,7 @@ class Diaspora
         * @param bool  $relay        Is the retraction transmitted from a relay?
         *
         * @return int The result of the transmission
+        * @throws \Exception
         */
        public static function sendRetraction(array $item, array $owner, array $contact, $public_batch = false, $relay = false)
        {
@@ -3894,6 +3983,8 @@ class Diaspora
         * @param array $contact Target of the communication
         *
         * @return int The result of the transmission
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
         */
        public static function sendMail(array $item, array $owner, array $contact)
        {
@@ -4004,6 +4095,7 @@ class Diaspora
         * @param int $uid The user id
         *
         * @return array The profile data
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function createProfileData($uid)
        {
@@ -4088,6 +4180,7 @@ class Diaspora
         * @param int  $uid    The user id
         * @param bool $recips optional, default false
         * @return void
+        * @throws \Exception
         */
        public static function sendProfile($uid, $recips = false)
        {
@@ -4129,6 +4222,7 @@ class Diaspora
         * @param array   $item Item array
         *
         * @return array Signed content
+        * @throws \Exception
         */
        public static function createLikeSignature($uid, array $item)
        {
@@ -4159,6 +4253,7 @@ class Diaspora
         * @param array   $item Item array
         *
         * @return array Signed content
+        * @throws \Exception
         */
        public static function createCommentSignature($uid, array $item)
        {