File: /home/xedaptot/ai.naniguide.com/app/Notifications/Admin/SendingServerWebhookProcessedOrphan.php
<?php
namespace App\Notifications\Admin;
use App\Model\SendingServer;
use App\Notifications\AppNotification;
use Illuminate\Database\Eloquent\Model;
/**
* Webhook handled cleanly (HTTP 200) but listener could not associate the
* runtime_message_id with a Customer/TrackingLog → no DB row written.
* Common cause: cache miss + tracking_log gone (TTL'd or never created
* because the original send happened on a different server).
*/
class SendingServerWebhookProcessedOrphan extends AppNotification
{
public function __construct(
public SendingServer $server,
public string $kind, // 'bounce' | 'complaint'
public string $runtimeMessageId,
public string $reason, // 'customer_not_found' | 'tracking_log_missing' | …
public ?string $rawPreview = null
) {}
public function audience(): string { return self::AUDIENCE_ADMINS; }
public function category(): string { return self::CATEGORY_ALERT; }
public function severity(): string { return self::SEVERITY_WARNING; }
public function subject(): ?Model
{
return $this->server;
}
public function toArray(object $notifiable = null): array
{
return [
'title' => sprintf('Orphan %s — %s', $this->kind, $this->reason),
'body' => sprintf(
'%s server "%s" received a %s for runtime_message_id=%s but listener could not associate it (reason: %s). No log row written.',
$this->server->type,
$this->server->name ?? ('#' . $this->server->id),
$this->kind,
$this->runtimeMessageId,
$this->reason
),
'meta' => ['raw' => $this->rawPreview],
];
}
}