Die Mail „Ihre Pressemitteilung wird persönlich geprüft“ verlinkte auch bei API-Meldungen in den Kundenbereich. Empfänger ohne Konto landeten auf der Passwort-Anmeldung. Wie in der Veröffentlichungs- und Ablehnungsmail schickt jetzt ein Klick einen Anmeldelink an die Adresse der Mail; die Zugangsseite übernimmt die Herkunft mail_review für den Funnel. Changelog: Verbessert Public: Auch die Mail zur persönlichen Prüfung führt Pressekontakte ohne Passwort zu ihrer Meldung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.5 KiB
PHP
97 lines
3.5 KiB
PHP
<?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 App\Services\Auth\MailAccessLink;
|
|
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;
|
|
|
|
/**
|
|
* Empfänger ohne Konto (API-Meldung, Roadmap 6.17): Adresse dieser Mail
|
|
* und Link, der einen Anmeldelink an sie schickt. Der Link zum Kundenbereich
|
|
* führte sonst auf eine Anmeldeseite für ein Konto, das der Empfänger
|
|
* nicht kennt.
|
|
*/
|
|
public ?string $accessEmail = null;
|
|
|
|
public ?string $accessUrl = null;
|
|
|
|
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->accessEmail = trim($recipientEmail);
|
|
$this->accessUrl = app(MailAccessLink::class)->url($this->accessEmail, $pressRelease, ConversionSource::MailReview);
|
|
$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');
|
|
}
|
|
}
|