From 8df8f73b32bdf2f60c18021dc4402001bea3a566 Mon Sep 17 00:00:00 2001 From: Adam Lavin Date: Sat, 1 May 2021 00:39:43 +0100 Subject: [PATCH] Prevent indexing tracks that shouldn't be indexed --- app/Traits/IndexedInElasticsearchTrait.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Traits/IndexedInElasticsearchTrait.php b/app/Traits/IndexedInElasticsearchTrait.php index 0ce53838..65594221 100644 --- a/app/Traits/IndexedInElasticsearchTrait.php +++ b/app/Traits/IndexedInElasticsearchTrait.php @@ -82,6 +82,11 @@ trait IndexedInElasticsearchTrait */ public function updateElasticsearchEntry(bool $removeFromIndex = false) { + // If it shouldn't be indexed, always force a removal from the index. + if (!$this->shouldBeIndexed()) { + $removeFromIndex = true; + } + $job = (new UpdateSearchIndexForEntity($this->getElasticsearchParameters(!$removeFromIndex), $removeFromIndex))->onQueue(config('ponyfm.indexing_queue')); $this->dispatch($job); }