]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Merge pull request #10377 from annando/warning
[friendica.git] / src / Protocol / Diaspora.php
index e973fcb85f683ccbe08c6664dcffbb64f8453de4..586b6e9ec282e8b425adfbf42adff5a71d995bcc 100644 (file)
@@ -2728,8 +2728,6 @@ class Diaspora
                if ($data->photo) {
                        foreach ($data->photo as $photo) {
                                self::storePhotoAsMedia($datarray['uri-id'], $photo);
-                               //$body = "[img]".XML::unescape($photo->remote_photo_path).
-                               //      XML::unescape($photo->remote_photo_name)."[/img]\n".$body;
                        }
 
                        $datarray["object-type"] = Activity\ObjectType::IMAGE;
@@ -2872,9 +2870,9 @@ class Diaspora
                        return false;
                }
 
-               $aes_key = openssl_random_pseudo_bytes(32);
+               $aes_key = random_bytes(32);
                $b_aes_key = base64_encode($aes_key);
-               $iv = openssl_random_pseudo_bytes(16);
+               $iv = random_bytes(16);
                $b_iv = base64_encode($iv);
 
                $ciphertext = self::aesEncrypt($aes_key, $iv, $msg);
@@ -3368,36 +3366,6 @@ class Diaspora
                return $eventdata;
        }
 
-       /**
-        * Add media attachments to the body
-        *
-        * @param array $item
-        * @return string body
-        */
-       private static function addAttachments(array $item)
-       {
-               $body = $item['body'];
-
-               foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::IMAGE, Post\Media::AUDIO, Post\Media::VIDEO]) as $media) {
-                       if (Item::containsLink($item['body'], $media['url'])) {
-                               continue;
-                       }
-
-                       if ($media['type'] == Post\Media::IMAGE) {
-                               if (!empty($media['description'])) {
-                                       $body .= "\n[img=" . $media['url'] . ']' . $media['description'] .'[/img]';
-                               } else {
-                                       $body .= "\n[img]" . $media['url'] .'[/img]';
-                               }
-                       } elseif ($media['type'] == Post\Media::AUDIO) {
-                               $body .= "\n[audio]" . $media['url'] . "[/audio]\n";
-                       } elseif ($media['type'] == Post\Media::VIDEO) {
-                               $body .= "\n[video]" . $media['url'] . "[/video]\n";
-                       }
-               }
-               return $body;
-       }
-
        /**
         * Create a post (status message or reshare)
         *
@@ -3438,7 +3406,7 @@ class Diaspora
                        $type = "reshare";
                } else {
                        $title = $item["title"];
-                       $body = self::addAttachments($item);
+                       $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
 
                        // Fetch the title from an attached link - if there is one
                        if (empty($item["title"]) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) {
@@ -3652,7 +3620,7 @@ class Diaspora
                        $thread_parent_item = Post::selectFirst(['guid', 'author-id', 'author-link', 'gravity'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
                }
 
-               $body = self::addAttachments($item);
+               $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
 
                // The replied to autor mention is prepended for clarity if:
                // - Item replied isn't yours
@@ -4081,13 +4049,11 @@ class Diaspora
                        return false;
                }
 
-               $parent = Post::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]);
-               if (!DBA::isResult($parent)) {
-                       return;
+               // This is only needed for the automated tests
+               if (empty($owner['uprvkey'])) {
+                       return false;
                }
 
-               $item['parent-uri'] = $parent['parent-uri'];
-
                $message = self::constructComment($item, $owner);
                if ($message === false) {
                        return false;