]> git.mxchange.org Git - friendica.git/commitdiff
Restore support for Mastodon profile short-form URLs
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 4 Oct 2023 00:46:17 +0000 (20:46 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 4 Oct 2023 00:46:17 +0000 (20:46 -0400)
- Running these URLs through WebFinger first allows to retrieve the canonical ActivityPub profile URL

src/Model/APContact.php

index c49017b595b120d3730e3d885417a7d4fedc4e27..5434bf584fa51df2455f1be2d883478194a4e2e0 100644 (file)
@@ -157,7 +157,10 @@ class APContact
 
                $apcontact = [];
 
-               $webfinger = empty(parse_url($url, PHP_URL_SCHEME));
+               // Mastodon profile short-form URL https://domain.tld/@user doesn't return AP data when queried
+               // with HTTPSignature::fetchRaw, but returns the correct data when provided to WebFinger
+               // @see https://github.com/friendica/friendica/issues/13359
+               $webfinger = empty(parse_url($url, PHP_URL_SCHEME)) || strpos($url, '@') !== false;
                if ($webfinger) {
                        $apcontact = self::fetchWebfingerData($url);
                        if (empty($apcontact['url'])) {
@@ -197,7 +200,7 @@ class APContact
                                $curlResult = HTTPSignature::fetchRaw($url);
                                $failed = empty($curlResult) || empty($curlResult->getBody()) ||
                                        (!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
-       
+
                                if (!$failed) {
                                        $data = json_decode($curlResult->getBody(), true);
                                        $failed = empty($data) || !is_array($data);