From d2a2e466ef6a822f4c6c4e0090aa7b00489feb9f Mon Sep 17 00:00:00 2001 From: Ghostie Date: Sat, 11 Jan 2025 19:16:26 -0500 Subject: [PATCH] added a very simple tag page --- .../Controllers/AP/APOutboxController.php | 4 ++++ app/Http/Controllers/HomeController.php | 9 ++++++++- app/Types/TypeActivity.php | 4 +++- app/Types/TypeActor.php | 17 +++++++++------- app/Types/TypeNote.php | 3 +++ resources/views/posts/tag.blade.php | 20 +++++++++++++++++++ resources/views/users/notifications.blade.php | 4 ++++ 7 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 resources/views/posts/tag.blade.php diff --git a/app/Http/Controllers/AP/APOutboxController.php b/app/Http/Controllers/AP/APOutboxController.php index ab58ef2..2c642ca 100644 --- a/app/Http/Controllers/AP/APOutboxController.php +++ b/app/Http/Controllers/AP/APOutboxController.php @@ -391,6 +391,10 @@ class APOutboxController extends Controller } $create_activity = TypeActivity::craft_create ($actor, $note); + + $create_activity->to = $note->to; + $create_activity->cc = $note->cc; + $note->activity_id = $create_activity->id; $note->save (); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 5450ddc..fb9988b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -58,7 +58,14 @@ class HomeController extends Controller public function tag ($tag) { - dd ($tag); + $tag_name = "#" . $tag; + $hashtag = Hashtag::where ("name", $tag_name)->first (); + if (!$hashtag) + return redirect ()->route ("browse"); + + $posts = $hashtag->get_notes ()->paginate (20); + + return view ("posts.tag", compact ("hashtag", "posts")); } public function search () diff --git a/app/Types/TypeActivity.php b/app/Types/TypeActivity.php index 1f72467..0044c27 100644 --- a/app/Types/TypeActivity.php +++ b/app/Types/TypeActivity.php @@ -16,7 +16,9 @@ class TypeActivity { public static function craft_response (Activity $activity) { $crafted_activity = [ - "@context" => "https://www.w3.org/ns/activitystreams", + "@context" => [ + "https://www.w3.org/ns/activitystreams", + ], "id" => $activity->activity_id, "type" => $activity->type, "actor" => $activity->actor, diff --git a/app/Types/TypeActor.php b/app/Types/TypeActor.php index 8c612db..999e562 100644 --- a/app/Types/TypeActor.php +++ b/app/Types/TypeActor.php @@ -209,14 +209,17 @@ class TypeActor { // we need to save the model first $actor->save (); - ProfileAttachment::where ("actor_id", $actor->id)->delete (); - foreach ($request ["attachment"] as $attachment) + if (isset ($request ["attachment"])) { - $profile_attachment = ProfileAttachment::create ([ - "actor_id" => $actor->id, - "name" => $attachment ["name"], - "content" => $attachment ["value"] - ]); + ProfileAttachment::where ("actor_id", $actor->id)->delete (); + foreach ($request ["attachment"] as $attachment) + { + $profile_attachment = ProfileAttachment::create ([ + "actor_id" => $actor->id, + "name" => $attachment ["name"], + "content" => $attachment ["value"] + ]); + } } $featured_items = TypeActor::actor_process_featured ($actor); diff --git a/app/Types/TypeNote.php b/app/Types/TypeNote.php index 14a4a9e..1c607d7 100644 --- a/app/Types/TypeNote.php +++ b/app/Types/TypeNote.php @@ -88,6 +88,9 @@ class TypeNote "tag" => $request ["tag"] ?? null, // TODO: This should change when I implement visibilities and private notes + "to" => [ + "https://www.w3.org/ns/activitystreams#Public" + ], "cc" => [ $actor->followers ] diff --git a/resources/views/posts/tag.blade.php b/resources/views/posts/tag.blade.php new file mode 100644 index 0000000..e3c887e --- /dev/null +++ b/resources/views/posts/tag.blade.php @@ -0,0 +1,20 @@ +@extends ("partials.layout") + +@section ("title", "Posts Tagged with " . $hashtag->name) + +@section ("content") +
+

Showing posts with tag: {{ $hashtag->name }}

+
+ + + + @foreach ($posts as $post) + + @endforeach + +
+ + {{ $posts->links("pagination::default") }} +
+@endsection diff --git a/resources/views/users/notifications.blade.php b/resources/views/users/notifications.blade.php index 1fcd338..56afd32 100644 --- a/resources/views/users/notifications.blade.php +++ b/resources/views/users/notifications.blade.php @@ -16,6 +16,10 @@ @foreach ($processed_notifications as $notification) + @if (!$notification ['actor'] || !$notification ['object']) + @continue + @endif + @if ($notification ['type'] == 'Signup')