From 145b5db9474e32ca3430fe35eaa7498d7f26ff95 Mon Sep 17 00:00:00 2001 From: winter Date: Sun, 16 Mar 2025 00:53:52 +0000 Subject: implement poking and such --- routes/actor.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'routes/actor.php') diff --git a/routes/actor.php b/routes/actor.php index d0bb066..a459640 100644 --- a/routes/actor.php +++ b/routes/actor.php @@ -1,5 +1,6 @@ mount('/actor/:id/unblock', function (array $args) { throw new Unauthorized('please authenticate yourself on behalf of the initiating actor'); } $initiator->unblock($target); +}); + +Router::getInstance()->mount('/actor/:id/poke', function (array $args) { + $target = Actor::find($args['id']); + if ($target == null || !$target->isLocal || $target->deleted) { + throw new NotFound(); + } + if (!$target->isPokeable()) { + throw new Forbidden('you may not poke this user!'); + } + $initiator = Actor::findByRequestHeaders(); + if ($initiator == null) { + throw new Unauthorized('please authenticate yourself on behalf of the initiating actor'); + } + $body = file_get_contents('php://input'); + $obj = json_decode($body); + $initiator->poke($target, PokeVerb::tryFrom($obj?->verb ?? '') ?? PokeVerb::POKE, $obj?->urgent ?? false); }); \ No newline at end of file -- cgit v1.3