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,12 +147,32 @@ new class extends Component {
])
->where('pubkey', $pubkey)->first();
if ($this->currentPleb) {
$this->profileForm->setPleb($this->currentPleb);
$this->form->setPleb($this->currentPleb);
$this->no = $this->currentPleb->no_email;
$this->showEmail = !$this->no;
if (!$this->currentPleb) {
return;
}
$this->profileForm->setPleb($this->currentPleb);
$this->form->setPleb($this->currentPleb);
$this->no = $this->currentPleb->no_email;
$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
@@ -1277,13 +1297,15 @@ new class extends Component {
Mitgliedsbeitrag
</h3>
<flux:callout variant="info" class="mb-6">
<p class="text-sm">
Nostr Event für die Zahlung des Mitgliedsbeitrags:
<span
class="block mt-2 font-mono text-xs break-all">{{ $currentPleb->paymentEvents->last()->event_id }}</span>
</p>
</flux:callout>
@if($currentPleb->paymentEvents->last())
<flux:callout variant="info" class="mb-6">
<p class="text-sm">
Nostr Event für die Zahlung des Mitgliedsbeitrags:
<span
class="block mt-2 font-mono text-xs break-all">{{ $currentPleb->paymentEvents->last()->event_id }}</span>
</p>
</flux:callout>
@endif
@if($invoiceStatusMessage)
<flux:callout variant="{{ $invoiceStatusVariant }}" class="mb-6">

View File

@@ -15,6 +15,20 @@ it('handles nostr login correctly', function () {
->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 () {
$pleb = EinundzwanzigPleb::factory()->create();