aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/push.php
diff options
context:
space:
mode:
authorwinter2024-12-19 18:01:29 +0000
committerwinter2024-12-19 18:01:29 +0000
commit1e070a7a0097c74f8ac30678d39267f19c76f9f6 (patch)
tree669ba608d8182971752f6bc2ae2ade0b3ff627cf /routes/push.php
parent6f767c4562df4a686720ef96396cea0b2f0c6334 (diff)
process pushes in job + fix token expiry job
Diffstat (limited to 'routes/push.php')
-rw-r--r--routes/push.php24
1 files changed, 5 insertions, 19 deletions
diff --git a/routes/push.php b/routes/push.php
index 6fc8229..f8771f2 100644
--- a/routes/push.php
+++ b/routes/push.php
@@ -3,10 +3,8 @@
use Digitigrade\HttpResponseStatus\BadRequest;
use Digitigrade\HttpResponseStatus\Forbidden;
use Digitigrade\HttpResponseStatus\Unauthorized;
-use Digitigrade\Model\Actor;
+use Digitigrade\Job\ProcessIncomingPush;
use Digitigrade\Model\Instance;
-use Digitigrade\Model\Interaction;
-use Digitigrade\Model\Note;
use Digitigrade\Router;
Router::getInstance()->mount('/push', function (array $args) {
@@ -33,21 +31,9 @@ Router::getInstance()->mount('/push', function (array $args) {
if (hostname_from_uri($obj->self) != $instance->domain) {
throw new Forbidden('you may not push objects belonging to a different instance');
}
-
- switch ($obj->type) {
- case 'actor':
- Actor::importFromReceivedObject($obj);
- break;
- case 'note':
- Note::importFromReceivedObject($obj);
- break;
- case 'interaction':
- Interaction::importFromReceivedObject($obj);
- break;
- case 'extension':
- case 'tombstone':
- throw new \RuntimeException('object type not yet implemented :(');
- default:
- throw new BadRequest('invalid object type');
+ if (!in_array($obj->type, ['actor', 'note', 'interaction', 'extension', 'tombstone'])) {
+ throw new BadRequest('invalid object type!');
}
+
+ (new ProcessIncomingPush($obj))->submit();
}); \ No newline at end of file