Merge pull request #10421 from annando/ap-photo

Transmit mediaType, preparation for header image
This commit is contained in:
Hypolite Petovan 2021-06-22 10:10:39 -04:00 committed by GitHub
commit b7bbb32739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View 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;

View File

@ -379,8 +379,27 @@ class Transmitter
'owner' => $contact['url'],
'publicKeyPem' => $user['pubkey']];
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
$data['icon'] = ['type' => 'Image',
'url' => $contact['photo']];
$data['icon'] = ['type' => 'Image', 'url' => $contact['photo']];
$resourceid = Photo::ridFromURI($contact['photo']);
if (!empty($resourceid)) {
$photo = Photo::selectFirst(['type'], ["resource-id" => $resourceid]);
if (!empty($photo['type'])) {
$data['icon']['mediaType'] = $photo['type'];
}
}
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();