Make use of NotificationEmailDeliveryBackgroundJob
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 22 Jun 2020 13:43:44 +0000 (15:43 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 22 Jun 2020 13:51:19 +0000 (15:51 +0200)
Fixes #2885

wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php

index 4672efdfa0dccaf4ff79a5c801c4edd9a3e3e8ee..7895753bfa058865d438d4a5f0cd514e4814c3da 100644 (file)
@@ -9,6 +9,8 @@ use wcf\data\user\notification\UserNotificationAction;
 use wcf\data\user\User;
 use wcf\data\user\UserEditor;
 use wcf\data\user\UserProfile;
+use wcf\system\background\job\NotificationEmailDeliveryBackgroundJob;
+use wcf\system\background\BackgroundQueueHandler;
 use wcf\system\cache\builder\UserNotificationEventCacheBuilder;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
@@ -726,7 +728,11 @@ class UserNotificationHandler extends SingletonFactory {
                        ]));
                }
                
-               $email->send();
+               $jobs = $email->getJobs();
+               foreach ($jobs as $job) {
+                       $wrappedJob = new NotificationEmailDeliveryBackgroundJob($job, $notification, $user);
+                       BackgroundQueueHandler::getInstance()->enqueueIn($wrappedJob);
+               }
        }
        
        /**