mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
TTS
This commit is contained in:
33
app/Events/PaidMessageEvent.php
Normal file
33
app/Events/PaidMessageEvent.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class PaidMessageEvent implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(public string $message, public string $checkid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function broadcastOn(): \Illuminate\Broadcasting\Channel|array
|
||||||
|
{
|
||||||
|
return new Channel('plebchannel');
|
||||||
|
}
|
||||||
|
}
|
||||||
87
app/Http/Livewire/Hello.php
Normal file
87
app/Http/Livewire/Hello.php
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
|
use App\Events\PaidMessageEvent;
|
||||||
|
use App\Traits\LNBitsTrait;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Livewire\Component;
|
||||||
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||||
|
use WireUi\Traits\Actions;
|
||||||
|
|
||||||
|
class Hello extends Component
|
||||||
|
{
|
||||||
|
use Actions;
|
||||||
|
use LNBitsTrait;
|
||||||
|
|
||||||
|
public $message = '';
|
||||||
|
public $qrCode = '';
|
||||||
|
public $invoice = '';
|
||||||
|
public $paymentHash = '';
|
||||||
|
public $checkid = null;
|
||||||
|
public bool $invoicePaid = false;
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'message' => 'required|string|max:255',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// {"url":"","wallet_id":"","read_key":""}
|
||||||
|
$invoice = $this->createInvoice(
|
||||||
|
sats: 21,
|
||||||
|
memo: 'Payment for: Bitcoin im Ländle 2023 - Code is Speech',
|
||||||
|
lnbits: [
|
||||||
|
'url' => 'https://legend.lnbits.com',
|
||||||
|
'wallet_id' => 'b9b095edd0db4bf8995f1bbc90b195c5',
|
||||||
|
'read_key' => '67e6d7f94f5345119d6c799d768a029e',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->notification()
|
||||||
|
->error('LNBits error: '.$e->getMessage());
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->paymentHash = $invoice['payment_hash'];
|
||||||
|
$this->qrCode = base64_encode(QrCode::format('png')
|
||||||
|
->size(300)
|
||||||
|
->merge('/public/img/einundzwanzig.png', .3)
|
||||||
|
->errorCorrection('H')
|
||||||
|
->generate($invoice['payment_request']));
|
||||||
|
$this->invoice = $invoice['payment_request'];
|
||||||
|
$this->checkid = $invoice['checking_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPaymentHash()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$invoice = $this->check($this->checkid, [
|
||||||
|
'url' => 'https://legend.lnbits.com',
|
||||||
|
'wallet_id' => 'b9b095edd0db4bf8995f1bbc90b195c5',
|
||||||
|
'read_key' => '67e6d7f94f5345119d6c799d768a029e',
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->notification()
|
||||||
|
->error('LNBits error: '.$e->getMessage());
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isset($invoice['paid']) && $invoice['paid']) {
|
||||||
|
$this->invoicePaid = true;
|
||||||
|
event(new PaidMessageEvent($this->message, $this->checkid));
|
||||||
|
} else {
|
||||||
|
Log::error(json_encode($invoice, JSON_THROW_ON_ERROR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.hello')->layout('layouts.guest');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ services:
|
|||||||
args:
|
args:
|
||||||
WWWGROUP: '${WWWGROUP}'
|
WWWGROUP: '${WWWGROUP}'
|
||||||
NOSTR_PRIVATE_KEY: '${NOSTR_PRIVATE_KEY}'
|
NOSTR_PRIVATE_KEY: '${NOSTR_PRIVATE_KEY}'
|
||||||
image: sail-8.2/app
|
image: sail-8.2/einundzwanzig
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- 'host.docker.internal:host-gateway'
|
- 'host.docker.internal:host-gateway'
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
31
resources/views/livewire/hello.blade.php
Normal file
31
resources/views/livewire/hello.blade.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="mt-10 flex flex-col items-center justify-center gap-x-6 bg-white pb-12">
|
||||||
|
@if(!$invoicePaid)
|
||||||
|
<div class="text-xl font-semibold text-gray-900 py-6">
|
||||||
|
Deine Nachricht wird live vorgelesen.
|
||||||
|
</div>
|
||||||
|
<div class="text-xl font-semibold text-gray-900 py-6 w-full px-12">
|
||||||
|
<x-textarea wire:model="message" label="Deine Nachricht hier" corner-hint="max. 255 Zeichen"/>
|
||||||
|
</div>
|
||||||
|
<div class="text-xl font-semibold text-gray-900 py-6">
|
||||||
|
{{ __('Click QR-Code to open your wallet') }}
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center" wire:key="qrcode">
|
||||||
|
<a href="lightning:{{ $this->invoice }}">
|
||||||
|
<img src="{{ 'data:image/png;base64, '. $this->qrCode }}"
|
||||||
|
alt="qrcode">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="text-xl font-semibold text-gray-900 py-6">
|
||||||
|
21 sats
|
||||||
|
</div>
|
||||||
|
<div wire:poll.keep-alive="checkPaymentHash"
|
||||||
|
wire:key="checkPaymentHash"></div>
|
||||||
|
@else
|
||||||
|
<div class="text-xl font-semibold text-gray-900 py-6">
|
||||||
|
Danke für deine Nachricht. Wenn alles klappt, dann werden wir die Nachricht gleich hören.
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -7,6 +7,10 @@ Route::middleware([])
|
|||||||
->get('/', \App\Http\Livewire\Frontend\Welcome::class)
|
->get('/', \App\Http\Livewire\Frontend\Welcome::class)
|
||||||
->name('welcome');
|
->name('welcome');
|
||||||
|
|
||||||
|
Route::middleware([])
|
||||||
|
->get('/hello', \App\Http\Livewire\Hello::class)
|
||||||
|
->name('hello');
|
||||||
|
|
||||||
Route::get('/img/{path}', \App\Http\Controllers\ImageController::class)
|
Route::get('/img/{path}', \App\Http\Controllers\ImageController::class)
|
||||||
->where('path', '.*')
|
->where('path', '.*')
|
||||||
->name('img');
|
->name('img');
|
||||||
|
|||||||
Reference in New Issue
Block a user