feat: add logic to create EinundzwanzigPleb if not exists in GetProfile API

This commit is contained in:
fsociety
2024-09-29 22:36:12 +02:00
parent 5988408bcc
commit 242bb3ce9a

View File

@@ -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();