aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-14 15:36:05 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-14 15:36:05 +0200
commit70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34 (patch)
tree5515907e5c06674e076429e597b77eb832bd53a2 /apps/comments/lib
parent1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8 (diff)
downloadnextcloud-server-70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34.tar.gz
nextcloud-server-70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34.zip
apply some polish
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/lib')
-rw-r--r--apps/comments/lib/EventHandler.php47
-rw-r--r--apps/comments/lib/Notification/Listener.php6
2 files changed, 15 insertions, 38 deletions
diff --git a/apps/comments/lib/EventHandler.php b/apps/comments/lib/EventHandler.php
index a5f312617e5..8c20c698371 100644
--- a/apps/comments/lib/EventHandler.php
+++ b/apps/comments/lib/EventHandler.php
@@ -36,12 +36,15 @@ use OCP\Comments\ICommentsEventHandler;
* @package OCA\Comments
*/
class EventHandler implements ICommentsEventHandler {
+ /** @var ActivityListener */
+ private $activityListener;
- /** @var Application */
- protected $app;
+ /** @var NotificationListener */
+ private $notificationListener;
- public function __construct(Application $app) {
- $this->app = $app;
+ public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
+ $this->activityListener = $activityListener;
+ $this->notificationListener = $notificationListener;
}
/**
@@ -55,30 +58,18 @@ class EventHandler implements ICommentsEventHandler {
$eventType = $event->getEvent();
if( $eventType === CommentsEvent::EVENT_ADD
- && $event instanceof CommentsEvent
) {
$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
- ) {
+ $applicableEvents = [
+ CommentsEvent::EVENT_PRE_UPDATE,
+ CommentsEvent::EVENT_UPDATE,
+ CommentsEvent::EVENT_DELETE,
+ ];
+ if(in_array($eventType, $applicableEvents)) {
$this->notificationHandler($event);
return;
}
@@ -88,21 +79,13 @@ class EventHandler implements ICommentsEventHandler {
* @param CommentsEvent $event
*/
private function activityHandler(CommentsEvent $event) {
- $c = $this->app->getContainer();
-
- /** @var ActivityListener $listener */
- $activityListener = $c->query(ActivityListener::class);
- $activityListener->commentEvent($event);
+ $this->activityListener->commentEvent($event);
}
/**
* @param CommentsEvent $event
*/
private function notificationHandler(CommentsEvent $event) {
- $c = $this->app->getContainer();
-
- /** @var NotificationListener $notificationListener */
- $notificationListener = $c->query(NotificationListener::class);
- $notificationListener->evaluate($event);
+ $this->notificationListener->evaluate($event);
}
}
diff --git a/apps/comments/lib/Notification/Listener.php b/apps/comments/lib/Notification/Listener.php
index 68705085023..426e85cac83 100644
--- a/apps/comments/lib/Notification/Listener.php
+++ b/apps/comments/lib/Notification/Listener.php
@@ -61,12 +61,6 @@ class Listener {
public function evaluate(CommentsEvent $event) {
$comment = $event->getComment();
- if($comment->getObjectType() !== 'files') {
- // comments App serves files only, other object types/apps need to
- // register their own ICommentsEventHandler and trigger notifications
- return;
- }
-
$mentions = $this->extractMentions($comment->getMessage());
if(empty($mentions)) {
// no one to notify