aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/actor.php24
-rw-r--r--routes/actor_profile_fragment.php14
-rw-r--r--routes/notifications.php2
3 files changed, 40 insertions, 0 deletions
diff --git a/routes/actor.php b/routes/actor.php
index a3b69d1..125c733 100644
--- a/routes/actor.php
+++ b/routes/actor.php
@@ -97,4 +97,28 @@ Router::getInstance()->mount('/actor/:id/rejectedFollow', function (array $args)
throw new Unauthorized('please authenticate yourself on behalf of the followed actor');
}
$target->rejectPendingFollowFrom($initiator);
+});
+
+Router::getInstance()->mount('/actor/:id/block', function (array $args) {
+ $target = Actor::find($args['id']);
+ if ($target == null || !$target->isLocal || $target->deleted) {
+ throw new NotFound();
+ }
+ $initiator = Actor::findByRequestHeaders();
+ if ($initiator == null) {
+ throw new Unauthorized('please authenticate yourself on behalf of the initiating actor');
+ }
+ $initiator->block($target);
+});
+
+Router::getInstance()->mount('/actor/:id/unblock', function (array $args) {
+ $target = Actor::find($args['id']);
+ if ($target == null || !$target->isLocal || $target->deleted) {
+ throw new NotFound();
+ }
+ $initiator = Actor::findByRequestHeaders();
+ if ($initiator == null) {
+ throw new Unauthorized('please authenticate yourself on behalf of the initiating actor');
+ }
+ $initiator->unblock($target);
}); \ No newline at end of file
diff --git a/routes/actor_profile_fragment.php b/routes/actor_profile_fragment.php
index 0a2a881..45f4487 100644
--- a/routes/actor_profile_fragment.php
+++ b/routes/actor_profile_fragment.php
@@ -46,6 +46,20 @@ Router::getInstance()->mount('/fragment/actor/:id/rejectPending', function (arra
render_template('actor_profile_pending_follow', ['response' => 'rejected']);
});
+Router::getInstance()->mount('/fragment/actor/:id/blockButton', function (array $args) {
+ $user = UserAccount::requireByCurrentSession();
+ $actor = Actor::find($args['id']);
+
+ if ($user->actor->blocks($actor)) {
+ // already blocking therefore unblock
+ $user->actor->unblock($actor);
+ } else {
+ $user->actor->block($actor);
+ }
+
+ render_template('actor_profile_block_button', ['user' => $user, 'actor' => $actor]);
+});
+
Router::getInstance()->mount('/fragment/profile', function (array $args) {
$user = UserAccount::requireByCurrentSession();
$actor = $user->actor;
diff --git a/routes/notifications.php b/routes/notifications.php
index 05fb89d..c7b9414 100644
--- a/routes/notifications.php
+++ b/routes/notifications.php
@@ -15,6 +15,8 @@ Router::getInstance()->mount('/notifications/partial', function (array $args) {
foreach ($notifs as $notif) {
$notif = $notif->toNotifyable();
+ if ($notif == null)
+ continue;
render_template('notification', [
'title' => $notif->getNotificationTitle(),
'body' => $notif->getNotificationBody(),