aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-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