diff --git a/app/Http/Controllers/FrontPageController.php b/app/Http/Controllers/FrontPageController.php index 52ff2adf..710e2da6 100644 --- a/app/Http/Controllers/FrontPageController.php +++ b/app/Http/Controllers/FrontPageController.php @@ -19,10 +19,6 @@ class FrontPageController extends Controller */ public function index(Request $request): Response|View { - if ($request->wantsActivityStream()) { - return (new ActivityStreamsService())->siteOwnerResponse(); - } - $notes = Note::latest()->with(['media', 'client', 'place'])->get(); $articles = Article::latest()->get(); $bookmarks = Bookmark::latest()->get(); diff --git a/app/Http/Controllers/NotesController.php b/app/Http/Controllers/NotesController.php index aea2bd76..c73c5f48 100644 --- a/app/Http/Controllers/NotesController.php +++ b/app/Http/Controllers/NotesController.php @@ -23,10 +23,6 @@ class NotesController extends Controller */ public function index(Request $request): View|Response { - if ($request->wantsActivityStream()) { - return (new ActivityStreamsService())->siteOwnerResponse(); - } - $notes = Note::latest() ->with('place', 'media', 'client') ->withCount(['webmentions As replies' => function ($query) { @@ -47,10 +43,6 @@ class NotesController extends Controller abort(404); } - if (request()->wantsActivityStream()) { - return (new ActivityStreamsService())->singleNoteResponse($note); - } - return view('notes.show', compact('note')); } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 67d7a2f4..c283cf9e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -30,11 +30,6 @@ class AppServiceProvider extends ServiceProvider { Note::observe(NoteObserver::class); - // Request AS macro - Request::macro('wantsActivityStream', function () { - return Str::contains(mb_strtolower($this->header('Accept')), 'application/activity+json'); - }); - // configure Intervention/Image $this->app->bind('Intervention\Image\ImageManager', function () { return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]); diff --git a/app/Services/ActivityStreamsService.php b/app/Services/ActivityStreamsService.php deleted file mode 100644 index e439e539..00000000 --- a/app/Services/ActivityStreamsService.php +++ /dev/null @@ -1,59 +0,0 @@ - 'https://www.w3.org/ns/activitystreams', - 'id' => config('app.url'), - 'type' => 'Person', - 'name' => config('user.displayname'), - 'preferredUsername' => config('user.username'), - ]); - - return response($data)->header('Content-Type', 'application/activity+json'); - } - - /** - * Return the relevant data to an AS2.0 request for a particular note. - */ - public function singleNoteResponse(Note $note): Response - { - $data = json_encode([ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'summary' => strtok(config('user.displayname'), ' ') . ' added a note to their microblog', - 'type' => 'Add', - 'published' => $note->updated_at->toW3cString(), - 'actor' => [ - 'type' => 'Person', - 'id' => config('app.url'), - 'name' => config('app.display_name'), - 'url' => config('app.url'), - 'image' => [ - 'type' => 'Link', - 'href' => config('app.url') . '/assets/img/profile.jpg', - 'mediaType' => '/image/jpeg', - ], - ], - 'object' => [ - 'id' => $note->longurl, - 'type' => 'Note', - 'url' => $note->longurl, - 'name' => strip_tags($note->note), - ], - ]); - - return response($data)->header('Content-Type', 'application/activity+json'); - } -} diff --git a/tests/Feature/ActivityStreamTest.php b/tests/Feature/ActivityStreamTest.php deleted file mode 100644 index ae6bb8ee..00000000 --- a/tests/Feature/ActivityStreamTest.php +++ /dev/null @@ -1,60 +0,0 @@ -get('/', ['Accept' => 'application/activity+json']); - $response->assertHeader('Content-Type', 'application/activity+json'); - $response->assertJson([ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'id' => config('app.url'), - 'type' => 'Person', - 'name' => config('user.displayname'), - ]); - } - - /** @test */ - public function notesPageContainsAuthorActivityStreamData(): void - { - $response = $this->get('/notes', ['Accept' => 'application/activity+json']); - $response->assertHeader('Content-Type', 'application/activity+json'); - $response->assertJson([ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'id' => config('app.url'), - 'type' => 'Person', - 'name' => config('user.displayname'), - ]); - } - - /** @test */ - public function requestForNoteIncludesActivityStreamData(): void - { - $note = Note::factory()->create(); - $response = $this->get($note->longurl, ['Accept' => 'application/activity+json']); - $response->assertHeader('Content-Type', 'application/activity+json'); - $response->assertJson([ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'type' => 'Add', - 'actor' => [ - 'type' => 'Person', - 'id' => config('app.url'), - ], - 'object' => [ - 'type' => 'Note', - 'name' => strip_tags($note->note), - ], - ]); - } -}