From bc9c83b6c33d460a574fbeb764c23bfbe941b4c0 Mon Sep 17 00:00:00 2001 From: winter Date: Thu, 23 Jan 2025 18:55:52 +0000 Subject: implement blocking users it doesn't work yet for notifications! but i think i got it in most other places --- templates/actor_profile.php | 4 +++- templates/actor_profile_block_button.php | 7 +++++++ templates/actor_profile_page.php | 2 ++ templates/note_hidden.php | 3 +++ templates/notifications_panel.php | 2 ++ templates/thread_page.php | 8 +++++++- 6 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 templates/actor_profile_block_button.php create mode 100644 templates/note_hidden.php (limited to 'templates') diff --git a/templates/actor_profile.php b/templates/actor_profile.php index 2947a72..cfcc510 100644 --- a/templates/actor_profile.php +++ b/templates/actor_profile.php @@ -17,7 +17,9 @@ $user = UserAccount::findByCurrentSession();
@getFullHandle() ?>
created->format('Y-m-d')) ?>
-
+
+ actor != $actor) + call_template('actor_profile_block_button', ['actor' => $actor, 'user' => $user]); ?> isLocal): ?> diff --git a/templates/actor_profile_block_button.php b/templates/actor_profile_block_button.php new file mode 100644 index 0000000..f82cc9a --- /dev/null +++ b/templates/actor_profile_block_button.php @@ -0,0 +1,7 @@ +actor->blocks($actor); +$action = $blocks ? 'unblock' : 'block'; +?> + \ No newline at end of file diff --git a/templates/actor_profile_page.php b/templates/actor_profile_page.php index eba9d04..3b6eb84 100644 --- a/templates/actor_profile_page.php +++ b/templates/actor_profile_page.php @@ -15,6 +15,8 @@ call_template('skeleton', [ $notes = Note::findAllWithAuthor($actor, 20); if (count($notes) == 0) { call_template('placeholder_text', ['message' => __('user.notes.placeholder')]); + } elseif ($user != null && $user->actor->blocks($actor)) { + call_template('placeholder_text', ['message' => __('user.profile.notesHidden')]); } else { foreach ($notes as $n) { if ($n->isViewableBy($user)) diff --git a/templates/note_hidden.php b/templates/note_hidden.php new file mode 100644 index 0000000..baad0d6 --- /dev/null +++ b/templates/note_hidden.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/templates/notifications_panel.php b/templates/notifications_panel.php index 3ca8faf..98a04e3 100644 --- a/templates/notifications_panel.php +++ b/templates/notifications_panel.php @@ -13,6 +13,8 @@ $notifications = Notification::findAllForUser($user, 50); } foreach ($notifications as $notif) { $notif = $notif->toNotifyable(); + if ($notif == null) + continue; call_template('notification', [ 'title' => $notif->getNotificationTitle(), 'body' => $notif->getNotificationBody(), diff --git a/templates/thread_page.php b/templates/thread_page.php index e5e5389..d16c6aa 100644 --- a/templates/thread_page.php +++ b/templates/thread_page.php @@ -1,5 +1,6 @@ '"' . $note->plainContent . '" - @' . $note->author->getFullHandle(), @@ -7,7 +8,12 @@ call_template('skeleton', [ ], function () { global $note; $notes = Note::findAllInThread($note->threadApex ?? $note); + $user = UserAccount::findByCurrentSession(); foreach ($notes as $n) { - call_template('note', ['note' => $n, 'selected' => $n == $note]); + if ($user != null && $user->actor->blocks($n->author)) { + call_template('note_hidden'); + } else { + call_template('note', ['note' => $n, 'selected' => $n == $note]); + } } }); \ No newline at end of file -- cgit v1.3