oldPid.':newpid-'.$this->newPid; } /** * Get the middleware the job should pass through. * * @return array */ public function middleware(): array { return [(new WithoutOverlapping('profile:migration:move-followers:oldpid-'.$this->oldPid.':newpid-'.$this->newPid))->shared()->dontRelease()]; } /** * Create a new job instance. */ public function __construct($oldPid, $newPid) { $this->oldPid = $oldPid; $this->newPid = $newPid; } /** * Execute the job. */ public function handle(): void { if ($this->batch()->cancelled()) { return; } $og = Profile::find($this->oldPid); $ne = Profile::find($this->newPid); if (! $og || ! $ne || $og == $ne) { return; } $targetInbox = $ne['sharedInbox'] ?? $ne['inbox_url']; foreach (Follower::whereFollowingId($this->oldPid)->lazyById(200, 'id') as $follower) { try { if ($targetInbox && $follower->local_profile) { $followerProfile = Profile::find($follower->profile_id); (new FollowerController)->sendFollow($followerProfile, $ne); } Follower::updateOrCreate([ 'profile_id' => $follower->profile_id, 'following_id' => $this->newPid, ]); } catch (Exception $e) { Log::error($e); } } AccountService::del($this->oldPid); AccountService::del($this->newPid); } }