diff options
author | Joas Schilling <coding@schilljs.com> | 2018-08-06 15:50:25 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-08-06 15:50:25 +0300 |
commit | 862bcbbae23d951365ea48eff0e6a9cc31b4e611 (patch) | |
tree | 6e4ddf9e2d8e59de3d2464beec36662dbd677c17 /lib | |
parent | c482cbb84790693bfc96cd1f1833cd5e95ea6100 (diff) |
Add the notification ID to the push to allow getting more details
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App.php | 2 | ||||
-rw-r--r-- | lib/Capabilities.php | 1 | ||||
-rw-r--r-- | lib/Push.php | 11 |
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/App.php b/lib/App.php index c1b966b..6be3dde 100644 --- a/lib/App.php +++ b/lib/App.php @@ -47,7 +47,7 @@ class App implements IApp { try { $notificationToPush = $this->handler->getById($notificationId, $notification->getUser()); - $this->push->pushToDevice($notificationToPush); + $this->push->pushToDevice($notificationId, $notificationToPush); } catch (NotificationNotFoundException $e) { throw new \InvalidArgumentException('Error while preparing push notification'); } diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 127d498..be654c1 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -48,6 +48,7 @@ class Capabilities implements ICapability { ], 'push' => [ 'devices', + 'object-data', ], 'admin-notifications' => [ 'ocs', diff --git a/lib/Push.php b/lib/Push.php index 11b091f..beade47 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -66,10 +66,7 @@ class Push { $this->log = $log; } - /** - * @param INotification $notification - */ - public function pushToDevice(INotification $notification) { + public function pushToDevice(int $id, INotification $notification) { $user = $this->userManager->get($notification->getUser()); if (!($user instanceof IUser)) { return; @@ -118,7 +115,7 @@ class Push { } try { - $payload = json_encode($this->encryptAndSign($userKey, $device, $notification, $isTalkNotification)); + $payload = json_encode($this->encryptAndSign($userKey, $device, $id, $notification, $isTalkNotification)); $proxyServer = rtrim($device['proxyserver'], '/'); if (!isset($pushNotifications[$proxyServer])) { @@ -175,17 +172,19 @@ class Push { /** * @param Key $userKey * @param array $device + * @param int $id * @param INotification $notification * @param bool $isTalkNotification * @return array * @throws InvalidTokenException * @throws \InvalidArgumentException */ - protected function encryptAndSign(Key $userKey, array $device, INotification $notification, bool $isTalkNotification): array { + protected function encryptAndSign(Key $userKey, array $device, int $id, INotification $notification, bool $isTalkNotification): array { // Check if the token is still valid... $this->tokenProvider->getTokenById($device['token']); $data = [ + 'nid' => $id, 'app' => $notification->getApp(), 'subject' => $notification->getParsedSubject(), 'type' => $notification->getObjectType(), |