Add notification filters
This commit is contained in:
@@ -9,14 +9,22 @@ use App\Models\NotificationDeliveryLog;
|
||||
|
||||
class QueueTicketStatusChangedNotificationDeliveries
|
||||
{
|
||||
public function __construct(
|
||||
private readonly MatchNotificationFilters $matchNotificationFilters,
|
||||
) {}
|
||||
|
||||
public function handle(TicketStatusChanged|TicketCreated $event): void
|
||||
{
|
||||
NotificationAction::query()
|
||||
->enabled()
|
||||
->where('project_id', $event->payload->projectId)
|
||||
->where('event_type', $event->payload->eventType->value)
|
||||
->get(['channel', 'id'])
|
||||
->get(['channel', 'filters', 'id'])
|
||||
->each(function (NotificationAction $notificationAction) use ($event): void {
|
||||
if (! $this->matchNotificationFilters->handle($notificationAction->filters ?? [], $event->payload)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notificationDeliveryLogId = null;
|
||||
|
||||
if (in_array($notificationAction->channel, [NotificationChannel::Discord, NotificationChannel::Webhook], true)) {
|
||||
|
||||
Reference in New Issue
Block a user