Allow to mention groupfolder users in file chats

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-09-29 11:52:55 +02:00
Родитель 8713553203
Коммит 73be7bece9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
3 изменённых файлов: 25 добавлений и 2 удалений

Просмотреть файл

@ -25,6 +25,9 @@ declare(strict_types=1);
namespace OCA\Talk\Files;
use OCA\GroupFolders\Mount\GroupFolderStorage;
use OCA\Files_Sharing\SharedStorage;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\FileInfo;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
@ -42,15 +45,19 @@ class Util {
private $session;
/** @var IShareManager */
private $shareManager;
/** @var IUserMountCache */
private $userMountCache;
/** @var array[] */
private $accessLists = [];
public function __construct(IRootFolder $rootFolder,
ISession $session,
IShareManager $shareManager) {
IShareManager $shareManager,
IUserMountCache $userMountCache) {
$this->rootFolder = $rootFolder;
$this->session = $session;
$this->shareManager = $shareManager;
$this->userMountCache = $userMountCache;
}
public function getUsersWithAccessFile(string $fileId): array {
@ -63,6 +70,16 @@ class Util {
$node = array_shift($nodes);
$accessList = $this->shareManager->getAccessList($node);
if (!$node->getStorage()->instanceOfStorage(SharedStorage::class)) {
// The file is not a shared file,
// let's check the accesslist for mount points of groupfolders and external storages
$mountsForFile = $this->userMountCache->getMountsForFileId($fileId);
$affectedUserIds = array_map(function (ICachedMountInfo $mount) {
return $mount->getUser()->getUID();
}, $mountsForFile);
$accessList['users'] = array_unique(array_merge($affectedUserIds, $accessList['users']));
}
$this->accessLists[$fileId] = $accessList['users'];
}

Просмотреть файл

@ -24,6 +24,7 @@
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQL94Platform" />
<referencedClass name="Doctrine\DBAL\Types\Types" />
<referencedClass name="OC" />
<referencedClass name="OCA\Files_Sharing\SharedStorage" />
</errorLevel>
</UndefinedClass>
<UndefinedDocblockClass>

Просмотреть файл

@ -25,6 +25,7 @@ namespace OCA\Talk\Tests\php\Files;
use OCA\GroupFolders\Mount\GroupFolderStorage;
use OCA\Talk\Files\Util;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\Node;
@ -100,10 +101,14 @@ class UtilTest extends TestCase {
/** @var IManager|MockObject $shareManager */
$shareManager = $this->createMock(IManager::class);
/** @var IUserMountCache|MockObject $userMountCache */
$userMountCache = $this->createMock(IUserMountCache::class);
$util = new Util(
$rootFolder,
$session,
$shareManager
$shareManager,
$userMountCache
);
$result = $util->getGroupFolderNode($fileId, $userId);
if ($return !== false) {