aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Service
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-01-10 11:20:21 +0100
committerJoas Schilling <coding@schilljs.com>2018-01-10 11:20:21 +0100
commit3af6d112ce9253e0bbb6e545c767253bd251d9a8 (patch)
treedd55694ba532253cc4217fc7d073d7534e26a32d /apps/files/lib/Service
parentda030b667d3ca8cbae8f02a72b2b2249a52b2e1a (diff)
downloadnextcloud-server-3af6d112ce9253e0bbb6e545c767253bd251d9a8.tar.gz
nextcloud-server-3af6d112ce9253e0bbb6e545c767253bd251d9a8.zip
Add events for favorites
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files/lib/Service')
-rw-r--r--apps/files/lib/Service/TagService.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/apps/files/lib/Service/TagService.php b/apps/files/lib/Service/TagService.php
index d812b16c30e..7437f0c31ad 100644
--- a/apps/files/lib/Service/TagService.php
+++ b/apps/files/lib/Service/TagService.php
@@ -31,6 +31,8 @@ use OCP\Files\Folder;
use OCP\ITags;
use OCP\IUser;
use OCP\IUserSession;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Service class to manage tags on files.
@@ -45,23 +47,28 @@ class TagService {
private $tagger;
/** @var Folder */
private $homeFolder;
+ /** @var EventDispatcherInterface */
+ private $dispatcher;
/**
* @param IUserSession $userSession
* @param IManager $activityManager
* @param ITags $tagger
* @param Folder $homeFolder
+ * @param EventDispatcherInterface $dispatcher
*/
public function __construct(
IUserSession $userSession,
IManager $activityManager,
ITags $tagger,
- Folder $homeFolder
+ Folder $homeFolder,
+ EventDispatcherInterface $dispatcher
) {
$this->userSession = $userSession;
$this->activityManager = $activityManager;
$this->tagger = $tagger;
$this->homeFolder = $homeFolder;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -114,6 +121,13 @@ class TagService {
return;
}
+ $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite';
+ $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [
+ 'userId' => $user->getUID(),
+ 'fileId' => $fileId,
+ 'path' => $path,
+ ]));
+
$event = $this->activityManager->generateEvent();
try {
$event->setApp('files')