diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-13 14:40:59 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-02-13 16:27:35 +0300 |
commit | 2aec53cb49e39d3ebfe0ff0d0137791f467ca94a (patch) | |
tree | 9a0055f054bd1321316955010d8feb7ec6ed2c6c /lib/Notification | |
parent | 0ab0e0f6dd118f6b447b75839141dff09ba3bd33 (diff) |
Use the datetime factory everywhere
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification')
-rw-r--r-- | lib/Notification/Hooks.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Notification/Hooks.php b/lib/Notification/Hooks.php index 6acd7bb1a..24d6666c2 100644 --- a/lib/Notification/Hooks.php +++ b/lib/Notification/Hooks.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace OCA\Spreed\Notification; use OCA\Spreed\Room; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\Notification\IManager; use OCP\ILogger; use OCP\IUser; @@ -32,18 +33,20 @@ class Hooks { /** @var IManager */ protected $notificationManager; - /** @var IUserSession */ protected $userSession; - + /** @var ITimeFactory */ + protected $timeFactory; /** @var ILogger */ protected $logger; public function __construct(IManager $notificationManager, IUserSession $userSession, + ITimeFactory $timeFactory, ILogger $logger) { $this->notificationManager = $notificationManager; $this->userSession = $userSession; + $this->timeFactory = $timeFactory; $this->logger = $logger; } @@ -61,7 +64,7 @@ class Hooks { $actorId = $actor->getUID(); $notification = $this->notificationManager->createNotification(); - $dateTime = new \DateTime(); + $dateTime = $this->timeFactory->getDateTime(); try { $notification->setApp('spreed') ->setDateTime($dateTime) @@ -132,7 +135,7 @@ class Hooks { $actorId = $actor instanceof IUser ? $actor->getUID() :''; $notification = $this->notificationManager->createNotification(); - $dateTime = new \DateTime(); + $dateTime = $this->timeFactory->getDateTime(); try { // Remove all old notifications for this room $notification->setApp('spreed') |