Reduce the usage of the "proxifyUrl" function

This commit is contained in:
Michael 2021-06-27 11:50:10 +00:00
parent 3fe6789c9c
commit b46b7b08ba
11 changed files with 205 additions and 71 deletions

View file

@ -67,17 +67,16 @@ class Attachment extends BaseFactory
$remote = $attachment['url'];
if ($type == 'image') {
if (Proxy::isLocalImage($attachment['url'])) {
$url = $attachment['url'];
$preview = $attachment['preview'] ?? $url;
$remote = '';
} else {
$url = Proxy::proxifyUrl($attachment['url']);
$preview = Proxy::proxifyUrl($attachment['url'], false, Proxy::SIZE_SMALL);
}
$url = Post\Media::getPreviewUrlForId($attachment['id']);
$preview = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_SMALL);
} else {
$url = Proxy::proxifyUrl($attachment['url']);
$preview = Proxy::proxifyUrl($attachment['preview'] ?? '');
$url = Proxy::proxifyUrl($attachment['url']);
if (!empty($attachment['preview'])) {
$preview = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_SMALL);
} else {
$preview = '';
}
}
$object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, $type, $url, $preview, $remote);

View file

@ -139,7 +139,7 @@ class Introduction extends BaseFactory
'madeby_zrl' => Contact::magicLink($notification['url']),
'madeby_addr' => $notification['addr'],
'contact_id' => $notification['contact-id'],
'photo' => (!empty($notification['fphoto']) ? Proxy::proxifyUrl($notification['fphoto'], false, Proxy::SIZE_SMALL) : Contact::DEFAULT_AVATAR_PHOTO),
'photo' => Contact::getAvatarUrlForUrl($notification['furl'], 0, Proxy::SIZE_SMALL),
'name' => $notification['fname'],
'url' => $notification['furl'],
'zrl' => Contact::magicLink($notification['furl']),

View file

@ -32,6 +32,7 @@ use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Session\ISession;
use Friendica\Database\Database;
use Friendica\Model\Contact;
use Friendica\Model\Post;
use Friendica\Module\BaseNotifications;
use Friendica\Network\HTTPException\InternalServerErrorException;
@ -239,7 +240,7 @@ class Notification extends BaseFactory
$formattedNotifications[] = new \Friendica\Object\Notification\Notification([
'label' => 'notification',
'link' => $this->baseUrl->get(true) . '/notification/' . $notification->id,
'image' => Proxy::proxifyUrl($notification->photo, false, Proxy::SIZE_MICRO),
'image' => Contact::getAvatarUrlForUrl($notification->url, $notification->uid, Proxy::SIZE_MICRO),
'url' => $notification->url,
'text' => strip_tags(BBCode::convert($notification->msg)),
'when' => DateTimeFormat::local($notification->date, 'r'),