aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/push.php
diff options
context:
space:
mode:
authorwinter2025-03-31 21:29:22 +0100
committerwinter2025-03-31 21:29:22 +0100
commita9f0003e809d46093e783d2079be7a952b5f5e0d (patch)
tree154cb0ad413756a265baebeee45a868d3ed79879 /routes/push.php
parent8c3f045ed44bcb27189a605a4b86e5db22fee4d6 (diff)
implement backfilling for newly discovered actors
Diffstat (limited to 'routes/push.php')
-rw-r--r--routes/push.php26
1 files changed, 3 insertions, 23 deletions
diff --git a/routes/push.php b/routes/push.php
index 344412c..2420f67 100644
--- a/routes/push.php
+++ b/routes/push.php
@@ -4,6 +4,7 @@ use Digitigrade\HttpResponseStatus\BadRequest;
use Digitigrade\HttpResponseStatus\Forbidden;
use Digitigrade\HttpResponseStatus\Unauthorized;
use Digitigrade\Job\ProcessIncomingPush;
+use Digitigrade\Job\ProcessIncomingSimplePush;
use Digitigrade\Model\Instance;
use Digitigrade\Router;
@@ -45,32 +46,11 @@ Router::getInstance()->mount('/push/simple', function (array $args) {
throw new BadRequest('dodgy looking uri!');
}
- $result = send_request_authenticated($uri);
- if (!str_contains($result->headers[0], '200')) {
- throw new BadRequest('unable to fetch that uri!');
- }
- $obj = json_decode($result->body);
-
- if ($obj === null) {
- throw new BadRequest("fetched content doesn't look like valid json");
- }
- if (!isset($obj->type, $obj->self)) {
- throw new BadRequest('the object needs to have `type` and `self` properties');
- }
- if ($obj->self != $uri) {
- throw new BadRequest('fetched object has a different uri from the one you gave me');
- }
- if (!in_array($obj->type, ['actor', 'note', 'interaction', 'extension', 'tombstone'])) {
- throw new BadRequest('invalid object type!');
- }
-
- // only add ratelimiting delay after having validated it, to mitigate the
- // possibility of denial-of-service attacks (still possible though)
// FIXME: use a proper rate limit system
sleep(5);
// and only add the job if the client actually waited for the delay time
if (!connection_aborted()) {
- // also wait a minute before processing the push
- (new ProcessIncomingPush($obj))->submitDelayed(60);
+ // submit it for later, to reduce abuse, theoretically
+ (new ProcessIncomingSimplePush($uri))->submitDelayed(60);
}
}); \ No newline at end of file