From 6f844ff40d936fb6591c2469dd9ff922bc4e575f Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 17 Dec 2024 23:05:43 +0000 Subject: implement interactions --- routes/interaction.php | 16 ++++++++++++++++ routes/push.php | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 routes/interaction.php (limited to 'routes') diff --git a/routes/interaction.php b/routes/interaction.php new file mode 100644 index 0000000..c50dec2 --- /dev/null +++ b/routes/interaction.php @@ -0,0 +1,16 @@ +mount('/interaction/:id', function (array $args) { + $interaction = Interaction::find($args['id']); + if ($interaction == null) { + throw new NotFound("i don't know that interaction"); + } + if (!$interaction->author->isLocal) { + throw new NotFound("i don't want to tell you about non-local interactions!"); + } + json_response($interaction); +}); \ No newline at end of file diff --git a/routes/push.php b/routes/push.php index 6712fb4..6fc8229 100644 --- a/routes/push.php +++ b/routes/push.php @@ -5,6 +5,7 @@ use Digitigrade\HttpResponseStatus\Forbidden; use Digitigrade\HttpResponseStatus\Unauthorized; use Digitigrade\Model\Actor; use Digitigrade\Model\Instance; +use Digitigrade\Model\Interaction; use Digitigrade\Model\Note; use Digitigrade\Router; @@ -41,6 +42,8 @@ Router::getInstance()->mount('/push', function (array $args) { Note::importFromReceivedObject($obj); break; case 'interaction': + Interaction::importFromReceivedObject($obj); + break; case 'extension': case 'tombstone': throw new \RuntimeException('object type not yet implemented :('); -- cgit v1.3