diff options
author | Joas Schilling <coding@schilljs.com> | 2019-01-09 17:16:10 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-01-09 17:16:10 +0300 |
commit | 39af02dbde784658d839b674273d3db377792860 (patch) | |
tree | fbcdaa6d6a537cc053796d5bf79ffab10f7e77a0 | |
parent | a1183f0c010ac0976485a09f7cf4a2fd4ac2f9cf (diff) | |
parent | c7bf65e180d2e065e30a3f03f251de5f30088f8a (diff) |
Merge branch 'bugfix/noid/notifications-for-private-events'v0.3.2
* bugfix/noid/notifications-for-private-events:
No longer trigger notification for private events
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | appinfo/info.xml | 2 | ||||
-rw-r--r-- | lib/Backend.php | 12 | ||||
-rw-r--r-- | lib/Notifier.php | 5 |
4 files changed, 22 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0af983e..bd1b121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All notable changes to this project will be documented in this file. +## 0.3.2 – 2019-01-09 +### Fixed +- Private events no longer trigger notifications for sharees + + ## 0.3.1 – 2018-12-01 ### Changed - Support for Nextcloud 15 diff --git a/appinfo/info.xml b/appinfo/info.xml index 098142b..ec44d9a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -6,7 +6,7 @@ <summary>Receive a notification when an event in a shared calendar was added, modified or deleted.</summary> <description><![CDATA[Receive a notification when an event in a shared calendar was added, modified or deleted.]]></description> - <version>0.3.1</version> + <version>0.3.2</version> <licence>agpl</licence> <author>Joas Schilling</author> diff --git a/lib/Backend.php b/lib/Backend.php index 4b1ab90..2de1cdd 100644 --- a/lib/Backend.php +++ b/lib/Backend.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace OCA\EventUpdateNotification; +use OCA\DAV\CalDAV\CalDavBackend; use OCP\Notification\IManager as INotificationManager; use OCP\IGroup; use OCP\IGroupManager; @@ -81,6 +82,7 @@ class Backend { return; } + $classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC; $action = $action . '_' . $object['type']; list ($dateTime, $hasTime) = $this->getNearestDateTime($objectData['calendardata']); $now = new \DateTime(); @@ -108,6 +110,13 @@ class Backend { continue; } + if ($classification === CalDavBackend::CLASSIFICATION_PRIVATE && $user !== $owner) { + // Private events are only available to the owner + continue; + } + + $isClassified = $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner; + $notification->setUser($user) ->setSubject($action, [ @@ -119,7 +128,8 @@ class Backend { ], 'object' => [ 'id' => $object['id'], - 'name' => $object['name'], + 'name' => $isClassified ? 'Busy' : $object['name'], + 'classified' => $isClassified, ], ] ); diff --git a/lib/Notifier.php b/lib/Notifier.php index 07fae97..ece3d08 100644 --- a/lib/Notifier.php +++ b/lib/Notifier.php @@ -151,6 +151,11 @@ class Notifier implements INotifier { throw new \InvalidArgumentException(' Invalid data'); } + if (!empty($eventData['classified'])) { + // Busy is stored untranslated in the database, so we translate it here. + $eventData['name'] = $this->l->t('Busy'); + } + return [ 'type' => 'calendar-event', 'id' => $eventData['id'], |