story = $story; } /** * Execute the job. * * @return void */ public function handle() { $story = $this->story; if ($story->local == false) { return; } StoryService::removeRotateQueue($story->id); StoryService::delLatest($story->profile_id); StoryService::delById($story->id); if (Storage::exists($story->path) == true) { Storage::delete($story->path); } $story->views()->delete(); $profile = $story->profile; $activity = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => $story->url().'#delete', 'type' => 'Delete', 'actor' => $profile->permalink(), 'object' => [ 'id' => $story->url(), 'type' => 'Story', ], ]; $this->fanoutExpiry($profile, $activity); // delete notifications // delete polls // delete reports $story->delete(); } protected function fanoutExpiry($profile, $activity) { $audience = FollowerService::softwareAudience($profile->id, 'pixelfed'); if (empty($audience)) { return; } $payload = json_encode($activity); $version = config('pixelfed.version'); $appUrl = config('app.url'); $userAgent = "(Pixelfed/{$version}; +{$appUrl})"; $timeout = config('federation.activitypub.delivery.timeout'); Http::pool(function (Pool $pool) use ($audience, $activity, $profile, $payload, $userAgent, $timeout) { foreach ($audience as $url) { $curlHeaders = HttpSignature::sign($profile, $url, $activity, [ 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'User-Agent' => $userAgent, ]); $headers = $this->parseCurlHeaders($curlHeaders); $pool->withHeaders($headers) ->timeout($timeout) ->withBody($payload, 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"') ->post($url); } }); } /** * Convert curl-format header array ("Header: value") to associative array. * * @param array $curlHeaders * @return array */ private function parseCurlHeaders(array $curlHeaders): array { $headers = []; foreach ($curlHeaders as $header) { $parts = explode(': ', $header, 2); if (count($parts) === 2) { $headers[$parts[0]] = $parts[1]; } } return $headers; } }