Add NIP-05 support and improve payment interaction handling

This commit is contained in:
HolgerHatGarKeineNode
2026-02-03 20:32:04 +01:00
parent 11399e7492
commit 71ce57ddd3
2 changed files with 48 additions and 12 deletions

View File

@@ -147,13 +147,33 @@ new class extends Component {
]) ])
->where('pubkey', $pubkey)->first(); ->where('pubkey', $pubkey)->first();
if ($this->currentPleb) { if (!$this->currentPleb) {
return;
}
$this->profileForm->setPleb($this->currentPleb); $this->profileForm->setPleb($this->currentPleb);
$this->form->setPleb($this->currentPleb); $this->form->setPleb($this->currentPleb);
$this->no = $this->currentPleb->no_email; $this->no = $this->currentPleb->no_email;
$this->showEmail = !$this->no; $this->showEmail = !$this->no;
if ($this->currentPleb->nip05_handle) {
$this->nip05VerifiedHandles = $this->getNip05HandlesForPubkey($this->currentPubkey);
if (count($this->nip05VerifiedHandles) > 0) {
$this->nip05Verified = true;
$this->nip05VerifiedHandle = $this->nip05VerifiedHandles[0];
if (!in_array($this->profileForm->nip05Handle, $this->nip05VerifiedHandles, true)) {
$this->nip05HandleMismatch = true;
} }
} }
}
$this->amountToPay = config('app.env') === 'production' ? 21000 : 1;
$this->resolveCurrentPaymentEvent();
$this->loadEvents();
$this->listenForPayment();
}
public function handleNostrLoggedOut(): void public function handleNostrLoggedOut(): void
{ {
@@ -1277,6 +1297,7 @@ new class extends Component {
Mitgliedsbeitrag Mitgliedsbeitrag
</h3> </h3>
@if($currentPleb->paymentEvents->last())
<flux:callout variant="info" class="mb-6"> <flux:callout variant="info" class="mb-6">
<p class="text-sm"> <p class="text-sm">
Nostr Event für die Zahlung des Mitgliedsbeitrags: Nostr Event für die Zahlung des Mitgliedsbeitrags:
@@ -1284,6 +1305,7 @@ new class extends Component {
class="block mt-2 font-mono text-xs break-all">{{ $currentPleb->paymentEvents->last()->event_id }}</span> class="block mt-2 font-mono text-xs break-all">{{ $currentPleb->paymentEvents->last()->event_id }}</span>
</p> </p>
</flux:callout> </flux:callout>
@endif
@if($invoiceStatusMessage) @if($invoiceStatusMessage)
<flux:callout variant="{{ $invoiceStatusVariant }}" class="mb-6"> <flux:callout variant="{{ $invoiceStatusVariant }}" class="mb-6">

View File

@@ -15,6 +15,20 @@ it('handles nostr login correctly', function () {
->assertSet('currentPleb.pubkey', $pleb->pubkey); ->assertSet('currentPleb.pubkey', $pleb->pubkey);
}); });
it('handles nostr login for active member and initializes payment state', function () {
$pleb = EinundzwanzigPleb::factory()->active()->create();
expect($pleb->paymentEvents()->count())->toBe(0);
Livewire::test('association.profile')
->call('handleNostrLoggedIn', $pleb->pubkey)
->assertSet('currentPubkey', $pleb->pubkey)
->assertSet('currentPleb.pubkey', $pleb->pubkey)
->assertSet('amountToPay', config('app.env') === 'production' ? 21000 : 1);
expect($pleb->paymentEvents()->count())->toBeGreaterThan(0);
});
it('handles nostr logout correctly', function () { it('handles nostr logout correctly', function () {
$pleb = EinundzwanzigPleb::factory()->create(); $pleb = EinundzwanzigPleb::factory()->create();