feat(notification): implement idempotent email delivery system and update related services
This commit is contained in:
44
app/Domains/Notification/Models/EmailDelivery.php
Normal file
44
app/Domains/Notification/Models/EmailDelivery.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Notification\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'idempotency_key',
|
||||
'email_type',
|
||||
'tenant_code',
|
||||
'status',
|
||||
'attempts',
|
||||
'context',
|
||||
'recipient_fingerprint',
|
||||
'claim_token',
|
||||
'claimed_at',
|
||||
'lease_expires_at',
|
||||
'sent_at',
|
||||
'failed_at',
|
||||
'last_error',
|
||||
])]
|
||||
class EmailDelivery extends Model
|
||||
{
|
||||
public const STATUS_PENDING = 'pending';
|
||||
|
||||
public const STATUS_PROCESSING = 'processing';
|
||||
|
||||
public const STATUS_SENT = 'sent';
|
||||
|
||||
public const STATUS_FAILED = 'failed';
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'attempts' => 'integer',
|
||||
'context' => 'array',
|
||||
'claimed_at' => 'datetime',
|
||||
'lease_expires_at' => 'datetime',
|
||||
'sent_at' => 'datetime',
|
||||
'failed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Notification\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'notification_key',
|
||||
'notification_type',
|
||||
'tenant_code',
|
||||
'event_date_id',
|
||||
'destination_event_date_id',
|
||||
'purchase_id',
|
||||
'sent_at',
|
||||
])]
|
||||
class EventDateNotificationDelivery extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'event_date_id' => 'integer',
|
||||
'destination_event_date_id' => 'integer',
|
||||
'purchase_id' => 'integer',
|
||||
'sent_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user