From 0a4f0d616a16926e731f900ecf64b3d08534613a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Dec 2023 10:39:41 +0000 Subject: [PATCH 1/2] Allow longer avatar URLs / the system outbox is now handled --- src/Model/APContact.php | 8 ++++---- src/Module/ActivityPub/Outbox.php | 3 +-- static/routes.config.php | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index c77e208186..53b70398e5 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -385,18 +385,18 @@ class APContact } // When the photo is too large, try to shorten it by removing parts - if (strlen($apcontact['photo'] ?? '') > 255) { + if (strlen($apcontact['photo'] ?? '') > 383) { $parts = parse_url($apcontact['photo']); unset($parts['fragment']); $apcontact['photo'] = (string)Uri::fromParts((array)$parts); - if (strlen($apcontact['photo']) > 255) { + if (strlen($apcontact['photo']) > 383) { unset($parts['query']); $apcontact['photo'] = (string)Uri::fromParts((array)$parts); } - if (strlen($apcontact['photo']) > 255) { - $apcontact['photo'] = substr($apcontact['photo'], 0, 255); + if (strlen($apcontact['photo']) > 383) { + $apcontact['photo'] = substr($apcontact['photo'], 0, 383); } } diff --git a/src/Module/ActivityPub/Outbox.php b/src/Module/ActivityPub/Outbox.php index e637a8e553..a0050b1ce4 100644 --- a/src/Module/ActivityPub/Outbox.php +++ b/src/Module/ActivityPub/Outbox.php @@ -21,7 +21,6 @@ namespace Friendica\Module\ActivityPub; -use Friendica\Core\System; use Friendica\Model\User; use Friendica\Module\BaseApi; use Friendica\Protocol\ActivityPub; @@ -36,7 +35,7 @@ class Outbox extends BaseApi protected function rawContent(array $request = []) { if (empty($this->parameters['nickname'])) { - throw new \Friendica\Network\HTTPException\NotFoundException(); + $this->jsonExit([], 'application/activity+json'); } $owner = User::getOwnerDataByNick($this->parameters['nickname']); diff --git a/static/routes.config.php b/static/routes.config.php index e1dbc6321b..8aa2d22ed9 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -452,6 +452,7 @@ return [ '/following/{nickname}' => [Module\ActivityPub\Following::class, [R::GET]], '/friendica[/{format:json}]' => [Module\Friendica::class, [R::GET]], '/friendica/inbox' => [Module\ActivityPub\Inbox::class, [R::GET, R::POST]], + '/friendica/outbox' => [Module\ActivityPub\Outbox::class, [R::GET]], '/fsuggest/{contact:\d+}' => [Module\FriendSuggest::class, [R::GET, R::POST]], From 303c9fb23f29a0a9a3330daaea6945fc45778955 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Dec 2023 11:19:11 +0000 Subject: [PATCH 2/2] Added server detection for "threads" --- src/Model/GServer.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 9d913f1c12..e00facde18 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -82,6 +82,7 @@ class GServer const DETECT_STATUS_PHP = 17; // Nextcloud const DETECT_V1_CONFIG = 18; const DETECT_SYSTEM_ACTOR = 20; // Mistpark, Osada, Roadhouse, Zap + const DETECT_THREADS = 21; // Standardized endpoints const DETECT_STATISTICS_JSON = 100; @@ -671,6 +672,12 @@ class GServer return false; } + if (in_array($url, ['https://www.threads.net', 'https://threads.net'])) { + $serverdata['detection-method'] = self::DETECT_THREADS; + $serverdata['network'] = Protocol::ACTIVITYPUB; + $serverdata['platform'] = 'threads'; + } + if (($serverdata['network'] == Protocol::PHANTOM) || in_array($serverdata['detection-method'], self::DETECT_UNSPECIFIC)) { $serverdata = self::detectMastodonAlikes($url, $serverdata); }