From bb41ddca5edeb3b3bae2fb44fc371790831d671c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Crnkovi=C4=87?= <6536260+crnkovic@users.noreply.github.com> Date: Wed, 8 Nov 2023 15:39:24 +0100 Subject: [PATCH] wip --- .../Controllers/RefreshedNftController.php | 4 ++- .../RefreshedNftControllerTest.php | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/RefreshedNftController.php b/app/Http/Controllers/RefreshedNftController.php index 48b0d62bd..fc02d2706 100644 --- a/app/Http/Controllers/RefreshedNftController.php +++ b/app/Http/Controllers/RefreshedNftController.php @@ -28,7 +28,9 @@ public function __invoke(Collection $collection, Nft $nft): JsonResponse $nft->touch('metadata_requested_at'); RefreshNftMetadata::dispatch()->onQueue(Queues::NFTS); - FetchCollectionActivity::dispatch($collection)->onQueue(Queues::NFTS); + if ($collection->indexesActivities()) { + FetchCollectionActivity::dispatch($collection)->onQueue(Queues::NFTS); + } return response()->json([ 'success' => true, diff --git a/tests/App/Http/Controllers/RefreshedNftControllerTest.php b/tests/App/Http/Controllers/RefreshedNftControllerTest.php index 77ccbf175..91ec8e3e1 100644 --- a/tests/App/Http/Controllers/RefreshedNftControllerTest.php +++ b/tests/App/Http/Controllers/RefreshedNftControllerTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use App\Jobs\FetchCollectionActivity; use App\Jobs\RefreshNftMetadata; use App\Models\Collection; use App\Models\Network; @@ -61,3 +62,27 @@ Bus::assertDispatchedTimes(RefreshNftMetadata::class, 0); }); + +it('should not dispatch the job to refresh the activity if collection does not index activity', function () { + Bus::fake(); + + $user = createUser(); + + $network = Network::polygon(); + + $collection = Collection::factory()->create([ + 'network_id' => $network->id, + 'supply' => null, + ]); + + $nft = Nft::factory()->create([ + 'wallet_id' => $user->wallet_id, + 'collection_id' => $collection->id, + ]); + + $this->actingAs($user) + ->post(route('nft.refresh', [$collection->slug, $nft->token_number])) + ->assertStatus(200); + + Bus::assertNotDispatched(FetchCollectionActivity::class); +});