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

github.com/nextcloud/event_update_notification.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2019-09-04 13:43:06 +0300
committerGitHub <noreply@github.com>2019-09-04 13:43:06 +0300
commit3068b13cc70e1e5b951f6d5af816a525fc7c03f2 (patch)
tree33ccc37d198cbdc2a918528fae82d65755ff863b
parent2ca1a9ac4d745469503fc6484954983d4f11b723 (diff)
parent9e966060c40b875b3f523af6db8e5751f3f92e11 (diff)
Merge pull request #11 from nickv-nextcloud/bugfix/noid/notification-adjustments
Adjust notifier to Nextcloud 17
-rw-r--r--appinfo/info.xml4
-rw-r--r--lib/AppInfo/Application.php10
-rw-r--r--lib/Backend.php4
-rw-r--r--lib/Notifier.php29
4 files changed, 29 insertions, 18 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml
index a7061dc..d4958bf 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.4</version>
+ <version>1.0.0</version>
<licence>agpl</licence>
<author>Joas Schilling</author>
@@ -27,6 +27,6 @@
<screenshot>https://github.com/nickv-nextcloud/event_update_notification/raw/master/docs/demo.png</screenshot>
<dependencies>
- <nextcloud min-version="14" max-version="16" />
+ <nextcloud min-version="17" max-version="17" />
</dependencies>
</info>
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 23b6e83..f277521 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -63,14 +63,6 @@ class Application extends App {
}
protected function registerNotifier() {
- $this->getContainer()->getServer()->getNotificationManager()->registerNotifier(function() {
- return $this->getContainer()->query(Notifier::class);
- }, function() {
- $l = $this->getContainer()->getServer()->getL10NFactory()->get('event_update_notification');
- return [
- 'id' => 'event_update_notification',
- 'name' => $l->t('Calendar event update notifications'),
- ];
- });
+ $this->getContainer()->getServer()->getNotificationManager()->registerNotifierService(Notifier::class);
}
}
diff --git a/lib/Backend.php b/lib/Backend.php
index 2de1cdd..77528ae 100644
--- a/lib/Backend.php
+++ b/lib/Backend.php
@@ -83,7 +83,7 @@ class Backend {
}
$classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC;
- $action = $action . '_' . $object['type'];
+ $action .= '_' . $object['type'];
list ($dateTime, $hasTime) = $this->getNearestDateTime($objectData['calendardata']);
$now = new \DateTime();
@@ -94,7 +94,7 @@ class Backend {
$notification = $this->notificationManager->createNotification();
$notification->setApp('event_update_notification')
- ->setObject('calendar', (int) $calendarData['id'])
+ ->setObject('calendar', (string) $calendarData['id'])
->setUser($currentUser)
->setDateTime($now)
->setMessage('event_update_notification', [
diff --git a/lib/Notifier.php b/lib/Notifier.php
index 8dcb492..205d1af 100644
--- a/lib/Notifier.php
+++ b/lib/Notifier.php
@@ -32,6 +32,7 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
+use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\IManager as INotificationManager;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
@@ -75,13 +76,33 @@ class Notifier implements INotifier {
}
/**
+ * Identifier of the notifier, only use [a-z0-9_]
+ *
+ * @return string
+ * @since 17.0.0
+ */
+ public function getID(): string {
+ return 'event_update_notification';
+ }
+
+ /**
+ * Human readable name describing the notifier
+ *
+ * @return string
+ * @since 17.0.0
+ */
+ public function getName(): string {
+ return $this->languageFactory->get('event_update_notification')->t('Calendar event update notifications');
+ }
+
+ /**
* @param INotification $notification
* @param string $languageCode The code of the language that should be used to prepare the notification
* @return INotification
* @throws \InvalidArgumentException When the notification was not prepared by a notifier
* @since 9.0.0
*/
- public function prepare(INotification $notification, $languageCode): INotification {
+ public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== 'event_update_notification') {
throw new \InvalidArgumentException('Invalid app');
}
@@ -97,16 +118,14 @@ class Notifier implements INotifier {
} else if ($notification->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event') {
$subject = $this->l->t('{actor} updated {event} in {calendar}');
} else {
- $this->notificationManager->markProcessed($notification);
- throw new \InvalidArgumentException('Invalid subject');
+ throw new AlreadyProcessedException();
}
$params = $notification->getMessageParameters();
$start = \DateTime::createFromFormat(\DateTime::ATOM, $params['start']);
if ($start < $this->timeFactory->getDateTime()) {
- $this->notificationManager->markProcessed($notification);
- throw new \InvalidArgumentException('Past event');
+ throw new AlreadyProcessedException();
}
if (!empty($params['hasTime'])) {