Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-04 16:46:47 +0300
committerJoas Schilling <coding@schilljs.com>2020-06-04 16:46:47 +0300
commit2d2cbf04954a0821b7a2fc87a5010a1adefa6b2e (patch)
tree851919c6d0f640b0b32247138e37945414c0a627 /lib/Notification
parentc2ab3395aa8522cf25eeebc40a99c72f8b332b28 (diff)
Dispatch an event to signal interest in defering the notifications
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification')
-rw-r--r--lib/Notification/Listener.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php
index 765a35f3c..51c270279 100644
--- a/lib/Notification/Listener.php
+++ b/lib/Notification/Listener.php
@@ -28,7 +28,10 @@ use OCA\Talk\Events\JoinRoomUserEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Room;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\GenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Notification\IApp;
use OCP\Notification\IManager;
use OCP\ILogger;
use OCP\IUser;
@@ -38,6 +41,8 @@ class Listener {
/** @var IManager */
protected $notificationManager;
+ /** @var IEventDispatcher */
+ protected $dispatcher;
/** @var IUserSession */
protected $userSession;
/** @var ITimeFactory */
@@ -49,10 +54,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 +207,7 @@ class Listener {
$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 +225,7 @@ class Listener {
->setDateTime($dateTime);
} catch (\InvalidArgumentException $e) {
$this->logger->logException($e, ['app' => 'spreed']);
+ $this->dispatcher->dispatch(IApp::class . '::flush', new Event());
return;
}
@@ -233,6 +242,7 @@ class Listener {
$this->logger->logException($e, ['app' => 'spreed']);
}
}
+ $this->dispatcher->dispatch(IApp::class . '::flush', new Event());
}
/**