From a9f0003e809d46093e783d2079be7a952b5f5e0d Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 31 Mar 2025 21:29:22 +0100 Subject: implement backfilling for newly discovered actors --- Digitigrade/Job/ProcessIncomingSimplePush.php | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Digitigrade/Job/ProcessIncomingSimplePush.php (limited to 'Digitigrade/Job/ProcessIncomingSimplePush.php') diff --git a/Digitigrade/Job/ProcessIncomingSimplePush.php b/Digitigrade/Job/ProcessIncomingSimplePush.php new file mode 100644 index 0000000..a48a70b --- /dev/null +++ b/Digitigrade/Job/ProcessIncomingSimplePush.php @@ -0,0 +1,44 @@ +uri = $uri; + $this->remainingTries = 3; + } + + public function run() { + $log = Logger::getInstance(); + + $log->info("processing simple push for $this->uri"); + + $result = send_request_authenticated($this->uri); + if (!str_contains($result->headers[0], '200')) { + throw new \RuntimeException("unable to fetch given simple push uri: $this->uri"); + } + $obj = json_decode($result->body); + + if ($obj === null) { + throw new \RuntimeException("fetched content doesn't look like valid json"); + } + if (!isset($obj->type, $obj->self)) { + throw new \RuntimeException('the object needs to have `type` and `self` properties'); + } + if ($obj->self != $this->uri) { + throw new \RuntimeException("fetched object has a different uri from the one provided ($obj->self != $this->uri)"); + } + + $log->info('fetch successful, pushed object will be dealt with soon'); + (new ProcessIncomingPush($obj))->submit(); + } + + public function submitDelayed(int $delaySecs) { + JobQueue::getInstance()->submitDelayed($this, $delaySecs); + } +} \ No newline at end of file -- cgit v1.3