Merge pull request #13135 from MrPetovan/bug/13108-photomenu-redir

Fix magic links in contact photo menu
This commit is contained in:
Tobias Diekershoff 2023-05-18 12:09:17 +02:00 committed by GitHub
commit d4d25c4e97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 16 deletions

View file

@ -378,7 +378,11 @@ class Item
'url' => $item['author-link'], 'url' => $item['author-link'],
]; ];
$profile_link = Contact::magicLinkByContact($author, $item['author-link']); $profile_link = Contact::magicLinkByContact($author, $item['author-link']);
$sparkle = (strpos($profile_link, 'contact/redir/') === 0); if (strpos($profile_link, 'contact/redir/') === 0) {
$status_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']);
$profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
}
$cid = 0; $cid = 0;
$pcid = $item['author-id']; $pcid = $item['author-id'];
@ -392,12 +396,6 @@ class Item
$rel = $contact['rel']; $rel = $contact['rel'];
} }
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (!empty($pcid)) { if (!empty($pcid)) {
$contact_url = 'contact/' . $pcid; $contact_url = 'contact/' . $pcid;
$posts_link = $contact_url . '/posts'; $posts_link = $contact_url . '/posts';

View file

@ -1152,10 +1152,11 @@ class Contact
$status_link = ''; $status_link = '';
$photos_link = ''; $photos_link = '';
$sparkle = false;
if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) { if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) {
$sparkle = true;
$profile_link = 'contact/redir/' . $contact['id']; $profile_link = 'contact/redir/' . $contact['id'];
$status_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/photos']);
$profile_link = $profile_link . '?' . http_build_query(['url' => $contact['url'] . '/profile']);
} else { } else {
$profile_link = $contact['url']; $profile_link = $contact['url'];
} }
@ -1164,12 +1165,6 @@ class Contact
$profile_link = ''; $profile_link = '';
} }
if ($sparkle) {
$status_link = $profile_link . '/status';
$photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) { if (self::canReceivePrivateMessages($contact) && empty($contact['pending'])) {
$pm_url = 'message/new/' . $contact['id']; $pm_url = 'message/new/' . $contact['id'];
} }
@ -3444,7 +3439,7 @@ class Contact
*/ */
public static function magicLinkByContact(array $contact, string $url = ''): string public static function magicLinkByContact(array $contact, string $url = ''): string
{ {
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url']; $destination = $url ?: $contact['url'];
if (!DI::userSession()->isAuthenticated()) { if (!DI::userSession()->isAuthenticated()) {
return $destination; return $destination;