diff --git a/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php b/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php new file mode 100644 index 000000000..64adebadc --- /dev/null +++ b/app/Jobs/HomeFeedPipeline/HashtagInsertFanoutPipeline.php @@ -0,0 +1,86 @@ +hashtag->id; + } + + /** + * Get the middleware the job should pass through. + * + * @return array + */ + public function middleware(): array + { + return [(new WithoutOverlapping("hfp:hashtag:fanout:insert:{$this->hashtag->id}"))->shared()->dontRelease()]; + } + + /** + * Create a new job instance. + */ + public function __construct(StatusHashtag $hashtag) + { + $this->hashtag = $hashtag; + } + + /** + * Execute the job. + */ + public function handle(): void + { + $hashtag = $this->hashtag; + + $ids = HashtagFollowService::getPidByHid($hashtag->hashtag_id); + + if(!$ids || !count($ids)) { + return; + } + + foreach($ids as $id) { + HomeTimelineService::add($id, $hashtag->status_id); + } + } +} diff --git a/app/Jobs/HomeFeedPipeline/HashtagRemoveFanoutPipeline.php b/app/Jobs/HomeFeedPipeline/HashtagRemoveFanoutPipeline.php new file mode 100644 index 000000000..92e3b8e42 --- /dev/null +++ b/app/Jobs/HomeFeedPipeline/HashtagRemoveFanoutPipeline.php @@ -0,0 +1,82 @@ +hid . ':' . $this->sid; + } + + /** + * Get the middleware the job should pass through. + * + * @return array + */ + public function middleware(): array + { + return [(new WithoutOverlapping("hfp:hashtag:fanout:remove:{$this->hid}:{$this->sid}"))->shared()->dontRelease()]; + } + + /** + * Create a new job instance. + */ + public function __construct($sid, $hid) + { + $this->sid = $sid; + $this->hid = $hid; + } + + /** + * Execute the job. + */ + public function handle(): void + { + $sid = $this->sid; + $hid = $this->hid; + + $ids = HashtagFollowService::getPidByHid($hid); + + if(!$ids || !count($ids)) { + return; + } + + foreach($ids as $id) { + HomeTimelineService::rem($id, $sid); + } + } +}