]> git.mxchange.org Git - friendica.git/commitdiff
Transmit mediaType for headers as well / use blank image for empty header
authorMichael <heluecht@pirati.ca>
Tue, 22 Jun 2021 13:58:29 +0000 (13:58 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 22 Jun 2021 13:58:29 +0000 (13:58 +0000)
src/Object/Api/Mastodon/Account.php
src/Protocol/ActivityPub/Transmitter.php

index 58a7c5ffe64d6d7fd0eb4127822efb5abe6dcddb..9b5639949d20e7622a6eb58edc8296c3d6b12f28 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\BaseDataTransferObject;
 use Friendica\Collection\Api\Mastodon\Fields;
 use Friendica\Content\Text\BBCode;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Proxy;
@@ -115,7 +116,7 @@ class Account extends BaseDataTransferObject
                $this->url             = $publicContact['url'];
                $this->avatar          = ($userContact['photo'] ?? $publicContact['photo']) ?: Proxy::proxifyUrl($userContact['avatar'] ?? $publicContact['avatar']);
                $this->avatar_static   = $this->avatar;
-               $this->header          = Proxy::proxifyUrl($userContact['header'] ?? $publicContact['header'] ?? '');
+               $this->header          = Proxy::proxifyUrl($userContact['header'] ?? $publicContact['header'] ?? '') ?: DI::baseUrl() . '/images/blank.png'; 
                $this->header_static   = $this->header;
                $this->followers_count = $apcontact['followers_count'] ?? 0;
                $this->following_count = $apcontact['following_count'] ?? 0;
index 17fd1b1502ee06d0c5ae2011e54e36df799d6d4d..435cab3d042276252dfa597da52a75b74a5e5487 100644 (file)
@@ -391,6 +391,14 @@ class Transmitter
 
                if (!empty($contact['header'])) {
                        $data['image'] = ['type' => 'Image', 'url' => $contact['header']];
+
+                       $resourceid = Photo::ridFromURI($contact['header']);
+                       if (!empty($resourceid)) {
+                               $photo = Photo::selectFirst(['type'], ["resource-id" => $resourceid]);
+                               if (!empty($photo['type'])) {
+                                       $data['image']['mediaType'] = $photo['type'];
+                               }
+                       }
                }
 
                $data['generator'] = self::getService();