diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index 765a35f3c0e..ec832633dc5 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -28,7 +28,9 @@ use OCA\Talk\Events\RoomEvent; use OCA\Talk\Room; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Notification\IApp; use OCP\Notification\IManager; use OCP\ILogger; use OCP\IUser; @@ -38,6 +40,8 @@ class Listener { /** @var IManager */ protected $notificationManager; + /** @var IEventDispatcher */ + protected $dispatcher; /** @var IUserSession */ protected $userSession; /** @var ITimeFactory */ @@ -49,10 +53,12 @@ class Listener { protected $shouldSendCallNotification = false; public function __construct(IManager $notificationManager, + IEventDispatcher $dispatcher, IUserSession $userSession, ITimeFactory $timeFactory, ILogger $logger) { $this->notificationManager = $notificationManager; + $this->dispatcher = $dispatcher; $this->userSession = $userSession; $this->timeFactory = $timeFactory; $this->logger = $logger; @@ -200,6 +206,7 @@ public function sendCallNotifications(Room $room): void { $actor = $this->userSession->getUser(); $actorId = $actor instanceof IUser ? $actor->getUID() :''; + $this->dispatcher->dispatch(IApp::class . '::defer', new Event()); $notification = $this->notificationManager->createNotification(); $dateTime = $this->timeFactory->getDateTime(); try { @@ -217,6 +224,7 @@ public function sendCallNotifications(Room $room): void { ->setDateTime($dateTime); } catch (\InvalidArgumentException $e) { $this->logger->logException($e, ['app' => 'spreed']); + $this->dispatcher->dispatch(IApp::class . '::flush', new Event()); return; } @@ -233,6 +241,7 @@ public function sendCallNotifications(Room $room): void { $this->logger->logException($e, ['app' => 'spreed']); } } + $this->dispatcher->dispatch(IApp::class . '::flush', new Event()); } /**