aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/actor.php
diff options
context:
space:
mode:
authorwinter2025-03-16 00:53:52 +0000
committerwinter2025-03-16 00:53:52 +0000
commit145b5db9474e32ca3430fe35eaa7498d7f26ff95 (patch)
treedf1da516a05cd382e19a815d4e7e6bee314e3007 /routes/actor.php
parenta0a86c3a98a6af158ecd2f1923feb752c82907db (diff)
implement poking and such
Diffstat (limited to 'routes/actor.php')
-rw-r--r--routes/actor.php19
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