Skip to content

Commit

Permalink
Add calendar trashbin support
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 6, 2021
1 parent 39f41e5 commit 6097d3a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## 1.3.0 – 2021-07-06
### Changed
- Support for Nextcloud 22 with calendar trashbin

## 1.2.0 – 2021-01-08
### Changed
- Support for Nextcloud 21
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>1.2.0</version>
<version>1.3.0</version>
<licence>agpl</licence>
<author>Joas Schilling</author>

Expand All @@ -27,6 +27,6 @@
<screenshot>https://github.com/nickv-nextcloud/event_update_notification/raw/master/docs/demo.png</screenshot>

<dependencies>
<nextcloud min-version="20" max-version="21" />
<nextcloud min-version="20" max-version="22" />
</dependencies>
</info>
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\DAV\Events\CalendarObjectDeletedEvent;
use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
use OCA\EventUpdateNotification\EventListener;
use OCA\EventUpdateNotification\Notifier;
Expand All @@ -43,6 +44,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(CalendarObjectCreatedEvent::class, EventListener::class);
$context->registerEventListener(CalendarObjectUpdatedEvent::class, EventListener::class);
$context->registerEventListener(CalendarObjectDeletedEvent::class, EventListener::class);
$context->registerEventListener(CalendarObjectMovedToTrashEvent::class, EventListener::class);
}

public function boot(IBootContext $context): void {
Expand Down
15 changes: 11 additions & 4 deletions lib/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\DAV\Events\CalendarObjectDeletedEvent;
use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
Expand Down Expand Up @@ -64,14 +65,20 @@ public function __construct(INotificationManager $notificationManager, IGroupMan
public function handle(Event $event): void {
if (!($event instanceof CalendarObjectCreatedEvent)
&& !($event instanceof CalendarObjectUpdatedEvent)
&& !($event instanceof CalendarObjectDeletedEvent)) {
&& !($event instanceof CalendarObjectDeletedEvent)
&& !($event instanceof CalendarObjectMovedToTrashEvent)) {
return;
}

$subject = Notifier::SUBJECT_OBJECT_ADD;
if ($event instanceof CalendarObjectUpdatedEvent) {
if ($event instanceof CalendarObjectCreatedEvent) {
$subject = Notifier::SUBJECT_OBJECT_ADD;
} else if ($event instanceof CalendarObjectUpdatedEvent) {
$subject = Notifier::SUBJECT_OBJECT_UPDATE;
} else if ($event instanceof CalendarObjectDeletedEvent) {
} else {
if ($event instanceof CalendarObjectDeletedEvent
&& substr($event->getObjectData()['uri'], -12) === '-deleted.ics') {
return;
}
$subject = Notifier::SUBJECT_OBJECT_DELETE;
}

Expand Down

0 comments on commit 6097d3a

Please sign in to comment.