зеркало из https://github.com/nextcloud/spreed.git
Receive shares in Talk/ folder
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
3cee014d1d
Коммит
dd1fd3bbe5
|
@ -49,6 +49,7 @@ use OCA\Talk\PublicShareAuth\Listener as PublicShareAuthListener;
|
|||
use OCA\Talk\PublicShareAuth\TemplateLoader as PublicShareAuthTemplateLoader;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Settings\Personal;
|
||||
use OCA\Talk\Share\Listener as ShareListener;
|
||||
use OCA\Talk\Share\RoomShareProvider;
|
||||
use OCA\Talk\Signaling\Listener as SignalingListener;
|
||||
use OCP\AppFramework\App;
|
||||
|
@ -103,6 +104,7 @@ class Application extends App {
|
|||
CollaboratorsListener::register($dispatcher);
|
||||
ResourceListener::register($dispatcher);
|
||||
ChangelogListener::register($dispatcher);
|
||||
ShareListener::register($dispatcher);
|
||||
Operation::register($dispatcher);
|
||||
|
||||
$dispatcher->addServiceListener(AddContentSecurityPolicyEvent::class, Listener\CSPListener::class);
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Share;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Share\Events\VerifyMountPointEvent;
|
||||
use OCP\Share\IShare;
|
||||
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);
|
||||
}
|
||||
|
||||
public static function overwriteShareTarget(GenericEvent $event): void {
|
||||
/** @var IShare $share */
|
||||
$share = $event->getSubject();
|
||||
|
||||
if ($share->getShareType() !== IShare::TYPE_ROOM
|
||||
&& $share->getShareType() !== RoomShareProvider::SHARE_TYPE_USERROOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target = RoomShareProvider::TALK_FOLDER_PLACEHOLDER . '/' . $share->getNode()->getName();
|
||||
$target = Filesystem::normalizePath($target);
|
||||
$share->setTarget($target);
|
||||
}
|
||||
|
||||
public static function overwriteMountPoint(VerifyMountPointEvent $event): void {
|
||||
$share = $event->getShare();
|
||||
|
||||
if ($share->getShareType() !== IShare::TYPE_ROOM
|
||||
&& $share->getShareType() !== RoomShareProvider::SHARE_TYPE_USERROOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($event->getParent() === RoomShareProvider::TALK_FOLDER_PLACEHOLDER) {
|
||||
$parent = RoomShareProvider::TALK_FOLDER; // FIXME user preference
|
||||
$event->setParent($parent);
|
||||
if (!$event->getView()->is_dir($parent)) {
|
||||
$event->getView()->mkdir($parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,6 +66,9 @@ class RoomShareProvider implements IShareProvider {
|
|||
// Special share type for user modified room shares
|
||||
public const SHARE_TYPE_USERROOM = 11;
|
||||
|
||||
public const TALK_FOLDER = '/Talk';
|
||||
public const TALK_FOLDER_PLACEHOLDER = '/{TALK_PLACEHOLDER}';
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $dbConnection;
|
||||
/** @var ISecureRandom */
|
||||
|
|
Загрузка…
Ссылка в новой задаче