press-releases: Mail "wird persoenlich geprueft" beim Block, Blade-Guard fuer @php-Bloecke (Roadmap 1d, Nachtrag)
Der Autor bekommt beim Block nach dem letzten Rot (oder Gelb mit eingeschalteter Queue) eine kurze Mail statt Stillstand: was passiert ist, dass nichts zu tun ist, und dass das Ergebnis per Mail kommt. Laeuft ueber notifyAuthor() wie Veroeffentlichung und Ablehnung (API-Regel, Sperrliste, adressbezogene Abmeldung, Bounce-Referenz); Opt-out am Typ "abgelehnt". Neue ConversionSource mail_review fuer den Link ins Konto. BladePhpBlockGuardTest wendet das Compiler-Muster auf alle Views an und faengt inline @php( vor einem spaeteren @endphp ab — fand den eigenen Erklaer-Kommentar im Modal, der nur zufaellig funktionierte. Regel in CLAUDE.md. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
35db30e019
commit
4fd1db7825
11 changed files with 278 additions and 24 deletions
84
app/Mail/PressReleaseHeldForReview.php
Normal file
84
app/Mail/PressReleaseHeldForReview.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Enums\ConversionSource;
|
||||
use App\Enums\EmailNotificationType;
|
||||
use App\Mail\Concerns\Unsubscribable;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* „Ein Mensch prüft jetzt" (Roadmap 1d, E3): Die Meldung ist nach dem
|
||||
* letzten erlaubten Rot — oder bei Gelb mit eingeschalteter Queue — nicht
|
||||
* abgelehnt, sondern zur persönlichen Prüfung zurückgehalten. Der Autor
|
||||
* muss nichts tun; das Ergebnis kommt als Veröffentlichungs- oder
|
||||
* Ablehnungsmail. Opt-out läuft über den Typ „abgelehnt": Wer keine
|
||||
* Prüfergebnisse will, will auch diesen Zwischenstand nicht.
|
||||
*/
|
||||
class PressReleaseHeldForReview extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels, Unsubscribable;
|
||||
|
||||
public string $showUrl;
|
||||
|
||||
/**
|
||||
* Name für die Anrede — bei API-Einlieferungen der Pressekontakt bzw.
|
||||
* die Firma, nie der Kontoname des API-Einlieferers.
|
||||
*/
|
||||
public string $recipientName;
|
||||
|
||||
public int $maxAttempts;
|
||||
|
||||
public function __construct(
|
||||
public readonly User $user,
|
||||
public readonly PressRelease $pressRelease,
|
||||
public readonly bool $automationExhausted,
|
||||
?string $recipientName = null,
|
||||
?string $recipientEmail = null,
|
||||
) {
|
||||
$this->recipientName = $recipientName ?? $user->name;
|
||||
$this->maxAttempts = max(1, (int) config('scoring.classification.max_automatic_attempts', 3));
|
||||
|
||||
$showUrl = $user->canAccessAdmin()
|
||||
? route('admin.press-releases.show', $pressRelease->id)
|
||||
: route('me.press-releases.show', $pressRelease->id);
|
||||
|
||||
$this->showUrl = $showUrl.(str_contains($showUrl, '?') ? '&' : '?').http_build_query([
|
||||
'src' => ConversionSource::MailReview->value,
|
||||
'pr' => $pressRelease->id,
|
||||
]);
|
||||
|
||||
if ($recipientEmail !== null && mb_strtolower(trim($recipientEmail)) !== mb_strtolower((string) $user->email)) {
|
||||
$this->configureAddressUnsubscribe($recipientEmail, EmailNotificationType::PressReleaseRejected);
|
||||
} else {
|
||||
$this->configureUnsubscribe($user, EmailNotificationType::PressReleaseRejected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bounce-Referenz für den DSN-Parser (Roadmap 1b.6), gesetzt über den
|
||||
* gemeinsamen headers() des Unsubscribable-Traits.
|
||||
*/
|
||||
public function bounceReference(): string
|
||||
{
|
||||
return sprintf('pm:%d:company:%s', $this->pressRelease->id, $this->pressRelease->company_id ?? '-');
|
||||
}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Ihre Pressemitteilung wird persönlich geprüft: '.$this->pressRelease->title,
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(view: 'emails.press-release.held-for-review');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue