diff options
| author | winter | 2025-01-23 18:55:52 +0000 |
|---|---|---|
| committer | winter | 2025-01-23 18:55:52 +0000 |
| commit | cc7cdfdd5fa49abffb5fd0e852db66bf6fe2cf14 (patch) | |
| tree | 0f1c0f148c09d572a990bd8317c2f5b135932744 /routes/actor.php | |
| parent | ddccaf16f39a4bf710266edc389fcde124e7ef56 (diff) | |
implement blocking users
it doesn't work yet for notifications! but i think i got it in most other places
Diffstat (limited to 'routes/actor.php')
| -rw-r--r-- | routes/actor.php | 24 |
1 files changed, 24 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 |
