Merge pull request #12905 from annando/issue-12858

Issue 12858: Peertube avatars can now be fetched
This commit is contained in:
Tobias Diekershoff 2023-03-18 07:55:19 +01:00 committed by GitHub
commit 7eed9e1818
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -29,7 +29,6 @@ use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\ActivityNamespace; use Friendica\Protocol\ActivityNamespace;
@ -259,6 +258,11 @@ class APContact
$apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id'); $apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) { if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
$apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id'); $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
} elseif (empty($apcontact['photo'])) {
$photo = JsonLD::fetchElementArray($compacted, 'as:icon', 'as:url');
if (!empty($photo[0]['@id'])) {
$apcontact['photo'] = $photo[0]['@id'];
}
} }
$apcontact['header'] = JsonLD::fetchElement($compacted, 'as:image', '@id'); $apcontact['header'] = JsonLD::fetchElement($compacted, 'as:image', '@id');

View file

@ -229,7 +229,12 @@ class Images
} }
if (empty($img_str)) { if (empty($img_str)) {
try {
$img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4); $img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4);
} catch (\Exception $exception) {
Logger::notice('Image is invalid', ['url' => $url, 'exception' => $exception]);
return [];
}
} }
if (!$img_str) { if (!$img_str) {