mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-13 05:26:47 +00:00
feat: add logic to create EinundzwanzigPleb if not exists in GetProfile API
This commit is contained in:
@@ -3,9 +3,11 @@
|
|||||||
namespace App\Http\Controllers\Api\Nostr;
|
namespace App\Http\Controllers\Api\Nostr;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\EinundzwanzigPleb;
|
||||||
use App\Models\Profile;
|
use App\Models\Profile;
|
||||||
use App\Traits\NostrFetcherTrait;
|
use App\Traits\NostrFetcherTrait;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use swentel\nostr\Key\Key;
|
||||||
|
|
||||||
class GetProfile extends Controller
|
class GetProfile extends Controller
|
||||||
{
|
{
|
||||||
@@ -17,6 +19,11 @@ class GetProfile extends Controller
|
|||||||
$this->fetchProfile([$key]);
|
$this->fetchProfile([$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create EinundzwanzigPleb if not exists
|
||||||
|
EinundzwanzigPleb::query()->firstOrCreate(['pubkey' => $key], [
|
||||||
|
'npub' => (new Key)->convertPublicKeyToBech32($key),
|
||||||
|
]);
|
||||||
|
|
||||||
return Profile::query()
|
return Profile::query()
|
||||||
->where('pubkey', $key)
|
->where('pubkey', $key)
|
||||||
->first();
|
->first();
|
||||||
|
|||||||
Reference in New Issue
Block a user