From 09aa496387ae732a2a27ab8d963f2e24192082cd Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Jun 2021 16:58:46 +0000 Subject: [PATCH 1/4] Some more places changed to the new contact avatar path format --- include/conversation.php | 2 +- src/Module/Xrd.php | 6 +++--- src/Network/Probe.php | 5 +++-- src/Object/Post.php | 6 +----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 24bb7434c..4bd6ce600 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -624,7 +624,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'indent' => '', 'owner_name' => '', 'owner_url' => '', - 'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']), + 'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)), 'plink' => Item::getPlink($item), 'edpost' => false, 'isstarred' => 'unstarred', diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index a58e915a7..d63fcb5ee 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -25,8 +25,8 @@ use Friendica\BaseModule; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\Core\System; -use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\Contact; use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Protocol\ActivityNamespace; @@ -183,7 +183,7 @@ class Xrd extends BaseModule [ 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $avatar['type'], - 'href' => $owner['photo'], + 'href' => Contact::getAvatarUrlForUrl($owner['url'], $owner['uid']), ], [ 'rel' => 'http://joindiaspora.com/seed_location', @@ -239,7 +239,7 @@ class Xrd extends BaseModule '$hcard_url' => $baseURL . '/hcard/' . $owner['nickname'], '$atom' => $owner['poll'], '$poco_url' => $owner['poco'], - '$photo' => $owner['photo'], + '$photo' => Contact::getAvatarUrlForUrl($owner['url'], $owner['uid']), '$type' => $avatar['type'], '$salmon' => $baseURL . '/salmon/' . $owner['nickname'], '$salmen' => $baseURL . '/salmon/' . $owner['nickname'] . '/mention', diff --git a/src/Network/Probe.php b/src/Network/Probe.php index d6ae415d3..e44a8d326 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -2222,8 +2222,9 @@ class Probe $data = ['name' => $profile['name'], 'nick' => $profile['nick'], 'guid' => $approfile['diaspora:guid'] ?? '', 'url' => $profile['url'], 'addr' => $profile['addr'], 'alias' => $profile['alias'], - 'photo' => $profile['photo'], 'header' => $profile['header'], 'account-type' => $profile['contact-type'], - 'community' => ($profile['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY), + 'photo' => Contact::getAvatarUrlForId($profile['id'], $profile['updated']), + 'header' => $profile['header'] ? Contact::getHeaderUrlForId($profile['id'], $profile['updated']) : '', + 'account-type' => $profile['contact-type'], 'community' => ($profile['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY), 'keywords' => $profile['keywords'], 'location' => $profile['location'], 'about' => $profile['about'], 'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $profile['notify'], 'poll' => $profile['poll'], 'request' => $profile['request'], 'confirm' => $profile['confirm'], diff --git a/src/Object/Post.php b/src/Object/Post.php index 57f2be4b5..089556a1f 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -69,7 +69,6 @@ class Post private $thread = null; private $redirect_url = null; private $owner_url = ''; - private $owner_photo = ''; private $owner_name = ''; private $wall_to_wall = false; private $threaded = false; @@ -474,7 +473,7 @@ class Post 'shiny' => $shiny, 'owner_self' => $item['author-link'] == Session::get('my_url'), 'owner_url' => $this->getOwnerUrl(), - 'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']), + 'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)), 'owner_name' => $this->getOwnerName(), 'plink' => Item::getPlink($item), 'edpost' => $edpost, @@ -1007,7 +1006,6 @@ class Post // Put this person as the wall owner of the wall-to-wall notice. $this->owner_url = Contact::magicLinkByContact($a->page_contact); - $this->owner_photo = $a->page_contact['thumb']; $this->owner_name = $a->page_contact['name']; $this->wall_to_wall = true; } elseif ($this->getDataValue('owner-link')) { @@ -1025,7 +1023,6 @@ class Post // But it could be somebody else with the same name. It just isn't highly likely. - $this->owner_photo = $this->getDataValue('owner-avatar'); $this->owner_name = $this->getDataValue('owner-name'); $this->wall_to_wall = true; @@ -1041,7 +1038,6 @@ class Post if (!$this->wall_to_wall) { $this->setTemplate('wall'); $this->owner_url = ''; - $this->owner_photo = ''; $this->owner_name = ''; } } From 98dd4e889a280da83b21934ded58d292bd92b63b Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Jun 2021 18:44:41 +0000 Subject: [PATCH 2/4] Some more contact paths --- src/Protocol/DFRN.php | 4 +++- src/Protocol/Feed.php | 3 ++- src/Protocol/OStatus.php | 12 ++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 194fa43fd..797a3973b 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -51,6 +51,7 @@ use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; use Friendica\Util\Network; +use Friendica\Util\Proxy; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -618,7 +619,8 @@ class DFRN XML::addElement($doc, $author, "dfrn:handle", $owner["addr"], $attributes); $attributes = ["rel" => "photo", "type" => "image/jpeg", - "media:width" => 300, "media:height" => 300, "href" => $owner['photo']]; + "media:width" => Proxy::PIXEL_SMALL, "media:height" => Proxy::PIXEL_SMALL, + "href" => Contact::getAvatarUrlForId($owner['id'], Proxy::SIZE_SMALL, $owner['updated'])]; if (!$public || !$hide) { $attributes["dfrn:updated"] = $picdate; diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index ebd6f5ed3..42f470e23 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -39,6 +39,7 @@ use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\ParseUrl; +use Friendica\Util\Proxy; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -957,7 +958,7 @@ class Feed XML::addElement($doc, $root, "id", DI::baseUrl() . "/profile/" . $owner["nick"]); XML::addElement($doc, $root, "title", $title); XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], DI::config()->get('config', 'sitename'))); - XML::addElement($doc, $root, "logo", $owner["photo"]); + XML::addElement($doc, $root, "logo", Contact::getAvatarUrlForId($owner['id'], Proxy::SIZE_SMALL, $owner['updated'])); XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM)); $author = self::addAuthor($doc, $owner); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 9de0138ad..38777d709 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1427,18 +1427,18 @@ class OStatus $attributes = [ "rel" => "avatar", "type" => "image/jpeg", // To-Do? - "media:width" => 300, - "media:height" => 300, - "href" => $owner["photo"]]; + "media:width" => ProxyUtils::SIZE_SMALL, + "media:height" => ProxyUtils::SIZE_SMALL, + "href" => Contact::getAvatarUrlForId($owner['id'], ProxyUtils::SIZE_SMALL, $owner['updated'])]; XML::addElement($doc, $author, "link", "", $attributes); if (isset($owner["thumb"])) { $attributes = [ "rel" => "avatar", "type" => "image/jpeg", // To-Do? - "media:width" => 80, - "media:height" => 80, - "href" => $owner["thumb"]]; + "media:width" => ProxyUtils::PIXEL_THUMB, + "media:height" => ProxyUtils::PIXEL_THUMB, + "href" => Contact::getAvatarUrlForId($owner['id'], ProxyUtils::SIZE_THUMB, $owner['updated'])]; XML::addElement($doc, $author, "link", "", $attributes); } From b46ad72651ecbb5eda333d10079eefcd971fe2e4 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Jun 2021 19:55:28 +0000 Subject: [PATCH 3/4] Fix media size --- src/Protocol/OStatus.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 38777d709..87be32fcd 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1427,8 +1427,8 @@ class OStatus $attributes = [ "rel" => "avatar", "type" => "image/jpeg", // To-Do? - "media:width" => ProxyUtils::SIZE_SMALL, - "media:height" => ProxyUtils::SIZE_SMALL, + "media:width" => ProxyUtils::PIXEL_SMALL, + "media:height" => ProxyUtils::PIXEL_SMALL, "href" => Contact::getAvatarUrlForId($owner['id'], ProxyUtils::SIZE_SMALL, $owner['updated'])]; XML::addElement($doc, $author, "link", "", $attributes); From 16de3454bc2bf49710c21356e91aab6d7ec23979 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Jun 2021 20:00:57 +0000 Subject: [PATCH 4/4] Change logo path --- src/Protocol/OStatus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 87be32fcd..919f327b8 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1272,7 +1272,7 @@ class OStatus XML::addElement($doc, $root, "id", DI::baseUrl() . "/profile/" . $owner["nick"]); XML::addElement($doc, $root, "title", $title); XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], DI::config()->get('config', 'sitename'))); - XML::addElement($doc, $root, "logo", $owner["photo"]); + XML::addElement($doc, $root, "logo", Contact::getAvatarUrlForId($owner['id'], ProxyUtils::SIZE_SMALL, $owner['updated'])); XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM)); $author = self::addAuthor($doc, $owner, true);