mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-18 11:04:22 +00:00
🔧 refactor(NostrFetcher): simplify filter assignment and add condition to fetch profiles only if available
This commit is contained in:
@@ -32,6 +32,8 @@ class SyncProfiles extends Command
|
|||||||
$plebs = EinundzwanzigPleb::query()
|
$plebs = EinundzwanzigPleb::query()
|
||||||
->whereDoesntHave('profile')
|
->whereDoesntHave('profile')
|
||||||
->get();
|
->get();
|
||||||
$this->fetchProfile($plebs->pluck('npub')->toArray());
|
if ($plebs->count() > 0) {
|
||||||
|
$this->fetchProfile($plebs->pluck('npub')->toArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ trait NostrFetcherTrait
|
|||||||
$filter1 = new Filter();
|
$filter1 = new Filter();
|
||||||
$filter1->setKinds([0]); // You can add multiple kind numbers
|
$filter1->setKinds([0]); // You can add multiple kind numbers
|
||||||
$filter1->setAuthors($hex->pluck('hex')->toArray()); // You can add multiple author ids
|
$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);
|
$requestMessage = new RequestMessage($subscriptionId, $filters);
|
||||||
|
|
||||||
$relayUrls = [
|
$relayUrls = [
|
||||||
@@ -69,7 +68,6 @@ trait NostrFetcherTrait
|
|||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
try {
|
try {
|
||||||
if (isset($item->event)) {
|
if (isset($item->event)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user