Halte Seiten mit zurückgezogenem Einstieg speicherbar und berechne den Link der Benachrichtigung in der Web-Anfrage
Das Widget prüft nur noch, dass der Einstieg existiert; die Auswahl im Editor bietet weiter nur veröffentlichte an. Der Worker kennt keine Anfrage und APP_URL ist unzuverlässig, daher gibt die Web-Anfrage die Adresse der Anfrage in der Verwaltung an die Aufgabe weiter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a495b0d740
commit
b9407c2f98
6 files changed
+39
-20
No files matched your search
@@ -74,11 +74,9 @@ public function dataFields(): array
|
||||
public function refRules(): array
|
||||
{
|
||||
return [
|
||||
'entry' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::exists('inquiry_entries', 'id')->where(fn ($query) => $query->whereNotNull('published_at')->whereNull('archived_at')),
|
||||
],
|
||||
// Nur die Existenz: Ein später zurückgezogener Einstieg darf eine Seite nicht unspeicherbar machen (Seiten bleiben
|
||||
// konsistent). Auswahl im Editor sind nur veröffentlichte Einstiege; öffentlich erscheint nichts, solange er es nicht ist.
|
||||
'entry' => ['required', 'integer', Rule::exists('inquiry_entries', 'id')],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public function submit(InquiryEntry $entry, array $payload): array
|
||||
|
||||
// Erst nach der Speicherung benachrichtigen. Ein Fehler hier verliert die Anfrage nie.
|
||||
try {
|
||||
SendInquiryNotification::dispatch($inquiry->id)->afterCommit();
|
||||
SendInquiryNotification::dispatch($inquiry->id, url('/verwaltung/anfragen/'.$inquiry->id))->afterCommit();
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
$inquiry->forceFill(['notification_error' => 'Die Benachrichtigung konnte nicht eingereiht werden: '.Str::limit($e->getMessage(), 300)])->save();
|
||||
|
||||
@@ -77,7 +77,7 @@ protected function getHeaderActions(): array
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Sendet die interne Benachrichtigung an die in den Einstellungen hinterlegten Empfänger noch einmal.')
|
||||
->action(function (): void {
|
||||
SendInquiryNotification::dispatchSync($this->getRecord()->id);
|
||||
SendInquiryNotification::dispatchSync($this->getRecord()->id, InquiryResource::getUrl('view', ['record' => $this->getRecord()]));
|
||||
$inquiry = $this->getRecord()->fresh();
|
||||
|
||||
if ($inquiry->notified_at !== null) {
|
||||
|
||||
@@ -21,7 +21,11 @@ class SendInquiryNotification implements ShouldQueue
|
||||
|
||||
public int $tries = 1;
|
||||
|
||||
public function __construct(public int $inquiryId) {}
|
||||
/**
|
||||
* @param ?string $adminUrl Adresse der Anfrage in der Verwaltung, während der Web-Anfrage berechnet: Im Worker
|
||||
* gibt es keine Anfrage, und APP_URL gilt in diesem Projekt nicht als verlässlich.
|
||||
*/
|
||||
public function __construct(public int $inquiryId, public ?string $adminUrl = null) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
@@ -40,7 +44,7 @@ public function handle(): void
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to($recipients)->send(new InquiryReceived($inquiry));
|
||||
Mail::to($recipients)->send(new InquiryReceived($inquiry, $this->adminUrl));
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
$inquiry->forceFill(['notification_error' => 'Der E-Mail-Versand ist fehlgeschlagen: '.Str::limit($e->getMessage(), 400)])->save();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
class InquiryReceived extends Mailable
|
||||
{
|
||||
public function __construct(public Inquiry $inquiry) {}
|
||||
public function __construct(public Inquiry $inquiry, public ?string $adminUrl = null) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public function content(): Content
|
||||
'reference' => $this->inquiry->reference,
|
||||
'issue' => $this->inquiry->issueTitle(),
|
||||
'received' => $this->inquiry->created_at?->timezone(config('app.timezone'))->format('d.m.Y H:i'),
|
||||
'url' => url('/verwaltung/anfragen/'.$this->inquiry->id),
|
||||
'url' => $this->adminUrl ?? url('/verwaltung/anfragen/'.$this->inquiry->id),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user