update Comment Listener
Signed-off-by: Chris Fritsche <chris.fritsche@cunio.de>
This commit is contained in:
parent
1e3c071aa5
commit
3a16939f15
|
@ -25,12 +25,15 @@
|
||||||
|
|
||||||
namespace OCA\Comments\Activity;
|
namespace OCA\Comments\Activity;
|
||||||
|
|
||||||
|
use OC\User\NoUserException;
|
||||||
use OCP\Activity\IManager;
|
use OCP\Activity\IManager;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\Comments\CommentsEvent;
|
use OCP\Comments\CommentsEvent;
|
||||||
use OCP\Files\Config\IMountProviderCollection;
|
use OCP\Files\Config\IMountProviderCollection;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\Node;
|
use OCP\Files\Node;
|
||||||
|
use OCP\Files\NotPermittedException;
|
||||||
|
use OCP\IConfig;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\Share\IShareHelper;
|
use OCP\Share\IShareHelper;
|
||||||
|
@ -40,14 +43,16 @@ class Listener {
|
||||||
protected $activityManager;
|
protected $activityManager;
|
||||||
/** @var IUserSession */
|
/** @var IUserSession */
|
||||||
protected $session;
|
protected $session;
|
||||||
/** @var \OCP\App\IAppManager */
|
/** @var IAppManager */
|
||||||
protected $appManager;
|
protected $appManager;
|
||||||
/** @var \OCP\Files\Config\IMountProviderCollection */
|
/** @var IMountProviderCollection */
|
||||||
protected $mountCollection;
|
protected $mountCollection;
|
||||||
/** @var \OCP\Files\IRootFolder */
|
/** @var IRootFolder */
|
||||||
protected $rootFolder;
|
protected $rootFolder;
|
||||||
/** @var IShareHelper */
|
/** @var IShareHelper */
|
||||||
protected $shareHelper;
|
protected $shareHelper;
|
||||||
|
/** @var IConfig */
|
||||||
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener constructor.
|
* Listener constructor.
|
||||||
|
@ -58,23 +63,28 @@ class Listener {
|
||||||
* @param IMountProviderCollection $mountCollection
|
* @param IMountProviderCollection $mountCollection
|
||||||
* @param IRootFolder $rootFolder
|
* @param IRootFolder $rootFolder
|
||||||
* @param IShareHelper $shareHelper
|
* @param IShareHelper $shareHelper
|
||||||
|
* @param IConfig $config
|
||||||
*/
|
*/
|
||||||
public function __construct(IManager $activityManager,
|
public function __construct(IManager $activityManager,
|
||||||
IUserSession $session,
|
IUserSession $session,
|
||||||
IAppManager $appManager,
|
IAppManager $appManager,
|
||||||
IMountProviderCollection $mountCollection,
|
IMountProviderCollection $mountCollection,
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder,
|
||||||
IShareHelper $shareHelper) {
|
IShareHelper $shareHelper,
|
||||||
|
IConfig $config) {
|
||||||
$this->activityManager = $activityManager;
|
$this->activityManager = $activityManager;
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
$this->appManager = $appManager;
|
$this->appManager = $appManager;
|
||||||
$this->mountCollection = $mountCollection;
|
$this->mountCollection = $mountCollection;
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
$this->shareHelper = $shareHelper;
|
$this->shareHelper = $shareHelper;
|
||||||
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CommentsEvent $event
|
* @param CommentsEvent $event
|
||||||
|
* @throws NotPermittedException
|
||||||
|
* @throws NoUserException
|
||||||
*/
|
*/
|
||||||
public function commentEvent(CommentsEvent $event) {
|
public function commentEvent(CommentsEvent $event) {
|
||||||
if ($event->getComment()->getObjectType() !== 'files'
|
if ($event->getComment()->getObjectType() !== 'files'
|
||||||
|
@ -102,6 +112,9 @@ class Listener {
|
||||||
$al = $this->shareHelper->getPathsForAccessList($node);
|
$al = $this->shareHelper->getPathsForAccessList($node);
|
||||||
$users += $al['users'];
|
$users += $al['users'];
|
||||||
}
|
}
|
||||||
|
if ($this->config->getSystemValueBool('activity_use_cached_mountpoints', false)) {
|
||||||
|
$users += [$owner => $this->getVisiblePath($mount->getPath())];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$actor = $this->session->getUser();
|
$actor = $this->session->getUser();
|
||||||
|
@ -133,4 +146,20 @@ class Listener {
|
||||||
$this->activityManager->publish($activity);
|
$this->activityManager->publish($activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $absolutePath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getVisiblePath(string $absolutePath): string {
|
||||||
|
$sections = explode('/', $absolutePath, 4);
|
||||||
|
|
||||||
|
$path = '/';
|
||||||
|
if (isset($sections[3])) {
|
||||||
|
// Not the case when a file in root is renamed
|
||||||
|
$path .= $sections[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue