File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -428,8 +428,8 @@ protected function createMessage()
428
428
*/
429
429
protected function sendSwiftMessage ($ message )
430
430
{
431
- if ($ this ->events ) {
432
- $ this -> events -> dispatch ( new Events \ MessageSending ( $ message )) ;
431
+ if (! $ this ->shouldSendMessage ( $ message ) ) {
432
+ return ;
433
433
}
434
434
435
435
try {
@@ -439,6 +439,23 @@ protected function sendSwiftMessage($message)
439
439
}
440
440
}
441
441
442
+ /**
443
+ * Determines if the message can be sent.
444
+ *
445
+ * @param \Swift_Message $message
446
+ * @return bool
447
+ */
448
+ protected function shouldSendMessage ($ message )
449
+ {
450
+ if (! $ this ->events ) {
451
+ return true ;
452
+ }
453
+
454
+ return $ this ->events ->until (
455
+ new Events \MessageSending ($ message )
456
+ ) !== false ;
457
+ }
458
+
442
459
/**
443
460
* Force the transport to re-connect.
444
461
*
You can’t perform that action at this time.
0 commit comments