status = $status; } /** * Execute the job. * * @return void */ public function handle() { $status = $this->status; if (! $status->reblog_of_id) { return; } $parent = Status::find($status->reblog_of_id); if (! $parent) { return; } $actor = $status->profile; $target = $parent->profile; if (! $actor || ! $target) { return; } $isRemoteShare = $status->uri !== null; $isSelfShare = (int) $target->id === (int) $actor->id; $targetIsLocal = $target->domain === null; ReblogService::addPostReblog($parent->profile_id, $status->id); if (Cache::add($this->counterGuardKey($status->id), 1, now()->addDays(30))) { Status::whereId($parent->id)->increment('reblogs_count'); StatusService::del($parent->id); } if ($targetIsLocal && ! $isSelfShare) { NotificationService::firstOrCreateNotification( $target->id, $actor->id, 'share', $status->reblog_of_id, Status::class ); } FeedInsertPipeline::dispatch($status->id, $status->profile_id)->onQueue('feed'); if ($isRemoteShare) { return; } return $this->remoteAnnounceDeliver(); } protected function counterGuardKey($statusId) { return 'pf:share-pipeline:counted:'.$statusId; } public function remoteAnnounceDeliver() { if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { return true; } $status = $this->status; if ($status->uri !== null) { return null; } $profile = $status->profile; if (! $profile || $profile->domain !== null) { return null; } if ($status->scope !== 'public') { return null; } $audience = $profile->getAudienceInbox(); if (empty($audience)) { return null; } $activity = FractalService::item($status, new Announce); ActivityPubDeliveryService::pool($profile, $audience, $activity); return null; } }