From b89c4f1cdcb4750745823f54e113fc3bb5b1fe21 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 25 Jun 2023 22:26:04 -0600 Subject: [PATCH] Update ActivityPubFetchService, fix authorized_fetch support --- .../Controllers/InstanceActorController.php | 56 ++++++++++++++++++- app/Models/InstanceActor.php | 56 ++++++++++++++++++- app/Services/ActivityPubFetchService.php | 1 - 3 files changed, 110 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/InstanceActorController.php b/app/Http/Controllers/InstanceActorController.php index 0eb796732..9e746fd5b 100644 --- a/app/Http/Controllers/InstanceActorController.php +++ b/app/Http/Controllers/InstanceActorController.php @@ -25,7 +25,61 @@ class InstanceActorController extends Controller public function outbox() { $res = json_encode([ - '@context' => 'https://www.w3.org/ns/activitystreams', + "@context" => [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + [ + "manuallyApprovesFollowers" => "as:manuallyApprovesFollowers", + "toot" => "http://joinmastodon.org/ns#", + "featured" => [ + "@id" => "toot:featured", + "@type" => "@id" + ], + "featuredTags" => [ + "@id" => "toot:featuredTags", + "@type" => "@id" + ], + "alsoKnownAs" => [ + "@id" => "as:alsoKnownAs", + "@type" => "@id" + ], + "movedTo" => [ + "@id" => "as:movedTo", + "@type" => "@id" + ], + "schema" => "http://schema.org#", + "PropertyValue" => "schema:PropertyValue", + "value" => "schema:value", + "discoverable" => "toot:discoverable", + "Device" => "toot:Device", + "Ed25519Signature" => "toot:Ed25519Signature", + "Ed25519Key" => "toot:Ed25519Key", + "Curve25519Key" => "toot:Curve25519Key", + "EncryptedMessage" => "toot:EncryptedMessage", + "publicKeyBase64" => "toot:publicKeyBase64", + "deviceId" => "toot:deviceId", + "claim" => [ + "@type" => "@id", + "@id" => "toot:claim" + ], + "fingerprintKey" => [ + "@type" => "@id", + "@id" => "toot:fingerprintKey" + ], + "identityKey" => [ + "@type" => "@id", + "@id" => "toot:identityKey" + ], + "devices" => [ + "@type" => "@id", + "@id" => "toot:devices" + ], + "messageFranking" => "toot:messageFranking", + "messageType" => "toot:messageType", + "cipherText" => "toot:cipherText", + "suspended" => "toot:suspended" + ] + ], 'id' => config('app.url') . '/i/actor/outbox', 'type' => 'OrderedCollection', 'totalItems' => 0, diff --git a/app/Models/InstanceActor.php b/app/Models/InstanceActor.php index 4636b10e9..d496e4b89 100644 --- a/app/Models/InstanceActor.php +++ b/app/Models/InstanceActor.php @@ -23,7 +23,61 @@ class InstanceActor extends Model public function getActor() { return [ - '@context' => 'https://www.w3.org/ns/activitystreams', + "@context" => [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + [ + "manuallyApprovesFollowers" => "as:manuallyApprovesFollowers", + "toot" => "http://joinmastodon.org/ns#", + "featured" => [ + "@id" => "toot:featured", + "@type" => "@id" + ], + "featuredTags" => [ + "@id" => "toot:featuredTags", + "@type" => "@id" + ], + "alsoKnownAs" => [ + "@id" => "as:alsoKnownAs", + "@type" => "@id" + ], + "movedTo" => [ + "@id" => "as:movedTo", + "@type" => "@id" + ], + "schema" => "http://schema.org#", + "PropertyValue" => "schema:PropertyValue", + "value" => "schema:value", + "discoverable" => "toot:discoverable", + "Device" => "toot:Device", + "Ed25519Signature" => "toot:Ed25519Signature", + "Ed25519Key" => "toot:Ed25519Key", + "Curve25519Key" => "toot:Curve25519Key", + "EncryptedMessage" => "toot:EncryptedMessage", + "publicKeyBase64" => "toot:publicKeyBase64", + "deviceId" => "toot:deviceId", + "claim" => [ + "@type" => "@id", + "@id" => "toot:claim" + ], + "fingerprintKey" => [ + "@type" => "@id", + "@id" => "toot:fingerprintKey" + ], + "identityKey" => [ + "@type" => "@id", + "@id" => "toot:identityKey" + ], + "devices" => [ + "@type" => "@id", + "@id" => "toot:devices" + ], + "messageFranking" => "toot:messageFranking", + "messageType" => "toot:messageType", + "cipherText" => "toot:cipherText", + "suspended" => "toot:suspended" + ] + ], 'id' => $this->permalink(), 'type' => 'Application', 'inbox' => $this->permalink('/inbox'), diff --git a/app/Services/ActivityPubFetchService.php b/app/Services/ActivityPubFetchService.php index 48cf6b0fe..f44779ab1 100644 --- a/app/Services/ActivityPubFetchService.php +++ b/app/Services/ActivityPubFetchService.php @@ -19,7 +19,6 @@ class ActivityPubFetchService $baseHeaders = [ 'Accept' => 'application/activity+json, application/ld+json', - 'User-Agent' => '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')' ]; $headers = HttpSignature::instanceActorSign($url, false, $baseHeaders);