diff options
Diffstat (limited to 'routes/actor.php')
| -rw-r--r-- | routes/actor.php | 19 |
1 files changed, 19 insertions, 0 deletions
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 @@ <?php +use Digitigrade\HttpResponseStatus\Forbidden; use Digitigrade\HttpResponseStatus\NotFound; use Digitigrade\HttpResponseStatus\PolicyRejected; use Digitigrade\HttpResponseStatus\TemporaryRedirect; @@ -9,6 +10,7 @@ use Digitigrade\Model\FollowRelationStatus; use Digitigrade\Model\Instance; use Digitigrade\Model\Note; use Digitigrade\Model\NotePrivacyScope; +use Digitigrade\PokeVerb; use Digitigrade\PolicyManager; use Digitigrade\Router; @@ -147,4 +149,21 @@ Router::getInstance()->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 |
