update api register
This commit is contained in:
@@ -40,12 +40,17 @@ class NotificationManager
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($event, $recipient, $subject, $payload, $occurrenceKey, $context, $tenantId) {
|
||||
$recipientOccurrenceKey = Str::limit(
|
||||
$occurrenceKey.'|'.$recipient->getMorphClass().'|'.$recipient->getKey(),
|
||||
255,
|
||||
''
|
||||
);
|
||||
$occurrence = NotificationEventOccurrence::firstOrCreate([
|
||||
'tenant_id' => $tenantId,
|
||||
'notification_event_id' => $event->id,
|
||||
'subjectable_type' => $subject->getMorphClass(),
|
||||
'subjectable_id' => $subject->getKey(),
|
||||
'occurrence_key' => $occurrenceKey,
|
||||
'occurrence_key' => $recipientOccurrenceKey,
|
||||
]);
|
||||
if (! $occurrence->wasRecentlyCreated) {
|
||||
return null;
|
||||
@@ -57,6 +62,20 @@ class NotificationManager
|
||||
->where('enabled', true)
|
||||
->orderBy('priority')
|
||||
->get();
|
||||
$systemConfigured = NotificationPreference::where('tenant_id', $tenantId)
|
||||
->where('notification_event_id', $event->id)
|
||||
->where('channel', 'system')
|
||||
->exists();
|
||||
if (! $systemConfigured && in_array('system', $event->available_channels ?? [], true)) {
|
||||
$preferences->prepend(new NotificationPreference([
|
||||
'tenant_id' => $tenantId,
|
||||
'notification_event_id' => $event->id,
|
||||
'channel' => 'system',
|
||||
'enabled' => true,
|
||||
'priority' => 1,
|
||||
'send_delay_minutes' => 0,
|
||||
]));
|
||||
}
|
||||
if ($preferences->isEmpty()) {
|
||||
$occurrence->update(['processed_at' => now()]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user