From af91859a4ddc778a406e55c53b6b7762cfe0abb6 Mon Sep 17 00:00:00 2001 From: fsociety Date: Wed, 16 Oct 2024 16:40:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20refactor(NostrFetcher):=20simpli?= =?UTF-8?q?fy=20filter=20assignment=20and=20add=20condition=20to=20fetch?= =?UTF-8?q?=20profiles=20only=20if=20available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Nostr/SyncProfiles.php | 4 +++- app/Traits/NostrFetcherTrait.php | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/Nostr/SyncProfiles.php b/app/Console/Commands/Nostr/SyncProfiles.php index 30667bf..6f4468d 100644 --- a/app/Console/Commands/Nostr/SyncProfiles.php +++ b/app/Console/Commands/Nostr/SyncProfiles.php @@ -32,6 +32,8 @@ class SyncProfiles extends Command $plebs = EinundzwanzigPleb::query() ->whereDoesntHave('profile') ->get(); - $this->fetchProfile($plebs->pluck('npub')->toArray()); + if ($plebs->count() > 0) { + $this->fetchProfile($plebs->pluck('npub')->toArray()); + } } } diff --git a/app/Traits/NostrFetcherTrait.php b/app/Traits/NostrFetcherTrait.php index 9c6c921..305c706 100644 --- a/app/Traits/NostrFetcherTrait.php +++ b/app/Traits/NostrFetcherTrait.php @@ -38,8 +38,7 @@ trait NostrFetcherTrait $filter1 = new Filter(); $filter1->setKinds([0]); // You can add multiple kind numbers $filter1->setAuthors($hex->pluck('hex')->toArray()); // You can add multiple author ids - $filters = [$filter1]; // You can add multiple filters. - + $filters = [$filter1]; $requestMessage = new RequestMessage($subscriptionId, $filters); $relayUrls = [ @@ -69,7 +68,6 @@ trait NostrFetcherTrait if (empty($data)) { return; } - foreach ($data as $item) { try { if (isset($item->event)) {