fixed notification system and added a new tenant notifications receipt table to track read status and filter messages by scope.

This commit is contained in:
Codex Agent
2025-12-17 10:57:19 +01:00
parent 0aae494945
commit d64839ba2f
31 changed files with 1089 additions and 127 deletions

View File

@@ -37,15 +37,26 @@ class SendTenantPackageExpiredNotification implements ShouldQueue
$tenant = $tenantPackage->tenant;
$context = [
'tenant_package_id' => $tenantPackage->id,
];
if ($this->isDuplicateNotification($tenant, 'package_expired', $context, ['tenant_package_id'])) {
$this->logNotification($tenant, [
'type' => 'package_expired',
'status' => 'skipped',
'context' => array_merge($context, ['reason' => 'duplicate']),
]);
return;
}
$preferences = app(\App\Services\Packages\TenantNotificationPreferences::class);
if (! $preferences->shouldNotify($tenant, 'package_expired')) {
$this->logNotification($tenant, [
'type' => 'package_expired',
'status' => 'skipped',
'context' => [
'tenant_package_id' => $tenantPackage->id,
'reason' => 'opt_out',
],
'context' => array_merge($context, ['reason' => 'opt_out']),
]);
return;
@@ -65,19 +76,12 @@ class SendTenantPackageExpiredNotification implements ShouldQueue
$this->logNotification($tenant, [
'type' => 'package_expired',
'status' => 'skipped',
'context' => [
'tenant_package_id' => $tenantPackage->id,
'reason' => 'no_recipient',
],
'context' => array_merge($context, ['reason' => 'no_recipient']),
]);
return;
}
$context = [
'tenant_package_id' => $tenantPackage->id,
];
$this->dispatchToRecipients(
$tenant,
$emails,