From 242bb3ce9a541134fb3ab27d181ec7e858f88449 Mon Sep 17 00:00:00 2001 From: fsociety Date: Sun, 29 Sep 2024 22:36:12 +0200 Subject: [PATCH] feat: add logic to create EinundzwanzigPleb if not exists in GetProfile API --- app/Http/Controllers/Api/Nostr/GetProfile.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/Api/Nostr/GetProfile.php b/app/Http/Controllers/Api/Nostr/GetProfile.php index 23e87d6..ea7ad5c 100644 --- a/app/Http/Controllers/Api/Nostr/GetProfile.php +++ b/app/Http/Controllers/Api/Nostr/GetProfile.php @@ -3,9 +3,11 @@ namespace App\Http\Controllers\Api\Nostr; use App\Http\Controllers\Controller; +use App\Models\EinundzwanzigPleb; use App\Models\Profile; use App\Traits\NostrFetcherTrait; use Illuminate\Http\Request; +use swentel\nostr\Key\Key; class GetProfile extends Controller { @@ -17,6 +19,11 @@ class GetProfile extends Controller $this->fetchProfile([$key]); } + // create EinundzwanzigPleb if not exists + EinundzwanzigPleb::query()->firstOrCreate(['pubkey' => $key], [ + 'npub' => (new Key)->convertPublicKeyToBech32($key), + ]); + return Profile::query() ->where('pubkey', $key) ->first();