Skip to content

Commit c161479

Browse files
authored
allow queueable notifications to set maxExceptions (#44773)
1 parent 7f5d349 commit c161479

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Illuminate/Notifications/SendQueuedNotifications.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class SendQueuedNotifications implements ShouldQueue
5050
*/
5151
public $timeout;
5252

53+
/**
54+
* The maximum number of unhandled exceptions to allow before failing.
55+
*
56+
* @var int
57+
*/
58+
public $maxExceptions;
59+
5360
/**
5461
* Indicates if the job should be encrypted.
5562
*
@@ -72,6 +79,7 @@ public function __construct($notifiables, $notification, array $channels = null)
7279
$this->notifiables = $this->wrapNotifiables($notifiables);
7380
$this->tries = property_exists($notification, 'tries') ? $notification->tries : null;
7481
$this->timeout = property_exists($notification, 'timeout') ? $notification->timeout : null;
82+
$this->maxExceptions = property_exists($notification, 'maxExceptions') ? $notification->maxExceptions : null;
7583
$this->afterCommit = property_exists($notification, 'afterCommit') ? $notification->afterCommit : null;
7684
$this->shouldBeEncrypted = $notification instanceof ShouldBeEncrypted;
7785
}

tests/Notifications/NotificationSendQueuedNotificationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ public function testSerializationOfNormalNotifiable()
5252

5353
$this->assertStringContainsString($serializedNotifiable, $serialized);
5454
}
55+
56+
public function testNotificationCanSetMaxExceptions()
57+
{
58+
$notifiable = new NotifiableUser;
59+
$notification = new class {
60+
public $maxExceptions = 23;
61+
};
62+
63+
$job = new SendQueuedNotifications($notifiable, $notification);
64+
65+
$this->assertEquals(23, $job->maxExceptions);
66+
}
5567
}
5668

5769
class NotifiableUser extends Model

0 commit comments

Comments
 (0)