]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Merge pull request #12819 from HankG/add-tables-to-optimize
[friendica.git] / src / Protocol / Diaspora.php
index 9f23fe13b763f5d4bd3641802a3129ad6d4516e3..271b71b893e1b20120a93a5bcf2da293d0a14443 100644 (file)
@@ -792,7 +792,7 @@ class Diaspora
         */
        private static function key(WebFingerUri $uri): string
        {
-               Logger::notice('Fetching diaspora key', ['handle' => $uri->getAddr(), 'callstack' => System::callstack(20)]);
+               Logger::info('Fetching diaspora key', ['handle' => $uri->getAddr(), 'callstack' => System::callstack(20)]);
                try {
                        return DI::dsprContact()->getByAddr($uri)->pubKey;
                } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
@@ -3316,10 +3316,16 @@ class Diaspora
 
                        $type = 'reshare';
                } else {
-                       $item['body'] = Post\Media::removeFromEndOfBody($item['body']);
+                       $native_photos = DI::config()->get('diaspora', 'native_photos');
+                       if ($native_photos) {
+                               $item['body'] = Post\Media::removeFromEndOfBody($item['body']);
+                               $attach_media = [Post\Media::AUDIO, Post\Media::VIDEO];
+                       } else {
+                               $attach_media = [Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO];
+                       }
 
                        $title = $item['title'];
-                       $body  = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item), [Post\Media::AUDIO, Post\Media::VIDEO]);
+                       $body  = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item), $attach_media);
 
                        // Fetch the title from an attached link - if there is one
                        if (empty($item['title']) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) {
@@ -3367,7 +3373,9 @@ class Diaspora
                                'location' => $location
                        ];
 
-                       $message = self::addPhotos($item, $message);
+                       if ($native_photos) {
+                               $message = self::addPhotos($item, $message);
+                       }
 
                        // Diaspora rejects messages when they contain a location without "lat" or "lng"
                        if (!isset($location['lat']) || !isset($location['lng'])) {
@@ -3403,6 +3411,13 @@ class Diaspora
                return $msg;
        }
 
+       /**
+        * Add photo elements to the message array
+        *
+        * @param array $item
+        * @param array $message
+        * @return array
+        */
        private static function addPhotos(array $item, array $message): array
        {
                $medias = Post\Media::getByURIId($item['uri-id'], [Post\Media::IMAGE]);