summaryrefslogtreecommitdiffstats
path: root/apps/comments/lib/EventHandler.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-12 18:06:22 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-12 18:06:22 +0200
commit1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8 (patch)
treee1af5850f05bfd165c3542f0b50a49fe623452c0 /apps/comments/lib/EventHandler.php
parenta9671a4dc2cc904ebb852c7804204ac9f245017e (diff)
downloadnextcloud-server-1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8.tar.gz
nextcloud-server-1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8.zip
emit pre-update event for comments
* notifications can be cleaned up, no polluted DB * updating comments will re-notify users or remove notifications, depending on the message Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/lib/EventHandler.php')
-rw-r--r--apps/comments/lib/EventHandler.php27
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/comments/lib/EventHandler.php b/apps/comments/lib/EventHandler.php
index 6692ccc520d..a5f312617e5 100644
--- a/apps/comments/lib/EventHandler.php
+++ b/apps/comments/lib/EventHandler.php
@@ -57,14 +57,29 @@ class EventHandler implements ICommentsEventHandler {
if( $eventType === CommentsEvent::EVENT_ADD
&& $event instanceof CommentsEvent
) {
- $this->onAdd($event);
+ $this->notificationHandler($event);
+ $this->activityHandler($event);
+ return;
+ }
+
+ if( $eventType === CommentsEvent::EVENT_PRE_UPDATE
+ && $event instanceof CommentsEvent
+ ) {
+ $this->notificationHandler($event);
+ return;
+ }
+
+ if( $eventType === CommentsEvent::EVENT_UPDATE
+ && $event instanceof CommentsEvent
+ ) {
+ $this->notificationHandler($event);
return;
}
if( $eventType === CommentsEvent::EVENT_DELETE
&& $event instanceof CommentsEvent
) {
- $this->onDelete($event);
+ $this->notificationHandler($event);
return;
}
}
@@ -72,13 +87,9 @@ class EventHandler implements ICommentsEventHandler {
/**
* @param CommentsEvent $event
*/
- private function onAdd(CommentsEvent $event) {
+ private function activityHandler(CommentsEvent $event) {
$c = $this->app->getContainer();
- /** @var NotificationListener $notificationListener */
- $notificationListener = $c->query(NotificationListener::class);
- $notificationListener->evaluate($event);
-
/** @var ActivityListener $listener */
$activityListener = $c->query(ActivityListener::class);
$activityListener->commentEvent($event);
@@ -87,7 +98,7 @@ class EventHandler implements ICommentsEventHandler {
/**
* @param CommentsEvent $event
*/
- private function onDelete(CommentsEvent $event) {
+ private function notificationHandler(CommentsEvent $event) {
$c = $this->app->getContainer();
/** @var NotificationListener $notificationListener */