Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Share
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-02-21 16:13:49 +0300
committerJoas Schilling <coding@schilljs.com>2020-03-06 13:10:45 +0300
commit03989f3c97954deeaa134e99a22e3c7246c1ad94 (patch)
tree987abd1b041cf2bacabc76335567656ab127990a /lib/Share
parentdd1fd3bbe5290fdfeae587105767a0a34c971a18 (diff)
Use the attachment_folder setting
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Share')
-rw-r--r--lib/Share/Listener.php31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/Share/Listener.php b/lib/Share/Listener.php
index 4114f8dae..13575fc46 100644
--- a/lib/Share/Listener.php
+++ b/lib/Share/Listener.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace OCA\Talk\Share;
use OC\Files\Filesystem;
+use OCA\Talk\Config;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Share\Events\VerifyMountPointEvent;
use OCP\Share\IShare;
@@ -31,11 +32,30 @@ use Symfony\Component\EventDispatcher\GenericEvent;
class Listener {
public static function register(IEventDispatcher $dispatcher): void {
- $dispatcher->addListener('OCP\Share::preShare', [self::class, 'overwriteShareTarget'], 1000);
- $dispatcher->addListener(VerifyMountPointEvent::class, [self::class, 'overwriteMountPoint'], 1000);
+ $dispatcher->addListener('OCP\Share::preShare', [self::class, 'listenPreShare'], 1000);
+ $dispatcher->addListener(VerifyMountPointEvent::class, [self::class, 'listenVerifyMountPointEvent'], 1000);
}
- public static function overwriteShareTarget(GenericEvent $event): void {
+ public static function listenPreShare(GenericEvent $event): void {
+ /** @var self $listener */
+ $listener = \OC::$server->query(self::class);
+ $listener->overwriteShareTarget($event);
+ }
+
+ public static function listenVerifyMountPointEvent(VerifyMountPointEvent $event): void {
+ /** @var self $listener */
+ $listener = \OC::$server->query(self::class);
+ $listener->overwriteMountPoint($event);
+ }
+
+ /** @var Config */
+ protected $config;
+
+ public function __construct(Config $config) {
+ $this->config = $config;
+ }
+
+ public function overwriteShareTarget(GenericEvent $event): void {
/** @var IShare $share */
$share = $event->getSubject();
@@ -49,8 +69,9 @@ class Listener {
$share->setTarget($target);
}
- public static function overwriteMountPoint(VerifyMountPointEvent $event): void {
+ public function overwriteMountPoint(VerifyMountPointEvent $event): void {
$share = $event->getShare();
+ $view = $event->getView();
if ($share->getShareType() !== IShare::TYPE_ROOM
&& $share->getShareType() !== RoomShareProvider::SHARE_TYPE_USERROOM) {
@@ -58,7 +79,7 @@ class Listener {
}
if ($event->getParent() === RoomShareProvider::TALK_FOLDER_PLACEHOLDER) {
- $parent = RoomShareProvider::TALK_FOLDER; // FIXME user preference
+ $parent = $this->config->getAttachmentFolder($view->getOwner('/'));
$event->setParent($parent);
if (!$event->getView()->is_dir($parent)) {
$event->getView()->mkdir($parent);