mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-14 06:36:46 +00:00
🔧 feat(NostrFetcher): add null check for event before processing JSON data in profile update
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Profile;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
@@ -71,10 +72,8 @@ trait NostrFetcherTrait
|
||||
|
||||
foreach ($data as $item) {
|
||||
try {
|
||||
if (isset($item->event)) {
|
||||
$result = json_decode($item->event->content, true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
throw new \RuntimeException('Error decoding JSON: ' . $e->getMessage());
|
||||
}
|
||||
Profile::query()->updateOrCreate(
|
||||
['pubkey' => $item->event->pubkey],
|
||||
[
|
||||
@@ -88,10 +87,13 @@ trait NostrFetcherTrait
|
||||
'lud16' => $result['lud16'] ?? null,
|
||||
'lud06' => $result['lud06'] ?? null,
|
||||
'deleted' => $result['deleted'] ?? false,
|
||||
]
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
} catch (\JsonException $e) {
|
||||
throw new \RuntimeException('Error decoding JSON: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user