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>2022-10-13 23:41:00 +0300
committerGitHub <noreply@github.com>2022-10-13 23:41:00 +0300
commit32a84561679303091c4b19479574e189ec792067 (patch)
tree397a429801c4921289eca9ff8ed06123754d65d9
parenta8b8cb68c671f19567eed96813998da2f04c2b6c (diff)
parent1a04bc57051126eaeb12f5523cd65c694da4a5da (diff)
Merge pull request #41 from nextcloud/feature/27/make-event-clickablev2.0.0
🌏 Make events clickable if calendar is installed
-rw-r--r--CHANGELOG.md7
-rw-r--r--lib/EventListener.php5
-rw-r--r--lib/Notifier.php28
-rw-r--r--tests/psalm-baseline.xml3
4 files changed, 39 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a59caad..df9e960 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,9 +2,12 @@
All notable changes to this project will be documented in this file.
## 2.0.0 – 2022-10-13
+### Added
+- 🌏 Make events clickable if calendar is installed
+
### Changed
-- Add support for Nextcloud 25
-- Drop support for Nextcloud 22
+- ✨ Add support for Nextcloud 25
+- 🏚️ Drop support for Nextcloud 22
## 1.5.0 – 2022-04-08
### Changed
diff --git a/lib/EventListener.php b/lib/EventListener.php
index bd1f354..c22defa 100644
--- a/lib/EventListener.php
+++ b/lib/EventListener.php
@@ -163,6 +163,11 @@ class EventListener implements IEventListener {
'id' => $object['id'],
'name' => $isClassified ? 'Busy' : $object['name'],
'classified' => $isClassified,
+ 'link' => [
+ 'owner' => $owner,
+ 'calendar_uri' => $calendarData['uri'],
+ 'object_uri' => $objectData['uri'],
+ ],
],
]
);
diff --git a/lib/Notifier.php b/lib/Notifier.php
index 0cea996..01d87fb 100644
--- a/lib/Notifier.php
+++ b/lib/Notifier.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OCA\EventUpdateNotification;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IDateTimeFormatter;
use OCP\IL10N;
@@ -55,6 +56,8 @@ class Notifier implements INotifier {
protected $userManager;
/** @var INotificationManager */
protected $notificationManager;
+ /** @var IAppManager */
+ protected $appManager;
/** @var IDateTimeFormatter */
protected $dateTimeFormatter;
@@ -66,12 +69,14 @@ class Notifier implements INotifier {
IURLGenerator $url,
IUserManager $userManager,
INotificationManager $notificationManager,
+ IAppManager $appManager,
IDateTimeFormatter $dateTimeFormatter) {
$this->languageFactory = $languageFactory;
$this->timeFactory = $timeFactory;
$this->url = $url;
$this->userManager = $userManager;
$this->notificationManager = $notificationManager;
+ $this->appManager = $appManager;
$this->dateTimeFormatter = $dateTimeFormatter;
}
@@ -191,11 +196,32 @@ class Notifier implements INotifier {
$eventData['name'] = $this->l->t('Busy');
}
- return [
+ $params = [
'type' => 'calendar-event',
'id' => $eventData['id'],
'name' => $eventData['name'],
];
+
+ if (isset($eventData['link']) && is_array($eventData['link']) && $this->appManager->isEnabledForUser('calendar')) {
+ try {
+ // The calendar app needs to be manually loaded for the routes to be loaded
+ \OC_App::loadApp('calendar');
+ $linkData = $eventData['link'];
+ $objectId = base64_encode('/remote.php/dav/calendars/' . $linkData['owner'] . '/' . $linkData['calendar_uri'] . '/' . $linkData['object_uri']);
+ $link = [
+ 'view' => 'dayGridMonth',
+ 'timeRange' => 'now',
+ 'mode' => 'sidebar',
+ 'objectId' => $objectId,
+ 'recurrenceId' => 'next'
+ ];
+ $params['link'] = $this->url->linkToRouteAbsolute('calendar.view.indexview.timerange.edit', $link);
+ } catch (\Exception $error) {
+ // Do nothing
+ }
+ }
+
+ return $params;
}
protected function generateCalendarParameter(array $data): array {
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
index 14412a9..5926dfe 100644
--- a/tests/psalm-baseline.xml
+++ b/tests/psalm-baseline.xml
@@ -27,9 +27,10 @@
</UndefinedDocblockClass>
</file>
<file src="lib/Notifier.php">
- <UndefinedClass occurrences="2">
+ <UndefinedClass occurrences="3">
<code>CalDavBackend</code>
<code>CalDavBackend</code>
+ <code>\OC_App</code>
</UndefinedClass>
</file>
</files>