From 0e77f5f73df1182787b9397e4daa80752ad1068a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 Feb 2026 11:36:24 +0100 Subject: [PATCH 1/2] test: Revert "TBD but for now all users with access to a file can be mentioned" This reverts commit a764cc199603e79b960f575560e3d666fd4936d1. Signed-off-by: Joas Schilling --- tests/integration/features/chat-2/mentions.feature | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integration/features/chat-2/mentions.feature b/tests/integration/features/chat-2/mentions.feature index cb934e8a36f..901776bacf2 100644 --- a/tests/integration/features/chat-2/mentions.feature +++ b/tests/integration/features/chat-2/mentions.feature @@ -444,7 +444,6 @@ Feature: chat/mentions | all | welcome.txt | calls | all | | participant1 | participant1-displayname | users | participant1 | | participant2 | participant2-displayname | users | participant2 | - | participant4 | participant4-displayname | users | participant4 | | participant3 | participant3-displayname | users | participant3 | | GUEST_ID | Guest | guests | GUEST_ID | # Guests can not mention users with access to the file that have not joined @@ -455,7 +454,6 @@ Feature: chat/mentions | participant1 | participant1-displayname | users | participant1 | | participant2 | participant2-displayname | users | participant2 | | participant3 | participant3-displayname | users | participant3 | - | participant4 | participant4-displayname | users | participant4 | | GUEST_ID | Guest | guests | GUEST_ID | Scenario: get matched mentions in a room for a file shared by link @@ -499,7 +497,6 @@ Feature: chat/mentions | id | label | source | mentionId | | participant1 | participant1-displayname | users | participant1 | | participant2 | participant2-displayname | users | participant2 | - | participant4 | participant4-displayname | users | participant4 | | participant3 | participant3-displayname | users | participant3 | # Guests can not mention users with access to the file that have not joined # the room. @@ -508,7 +505,6 @@ Feature: chat/mentions | participant1 | participant1-displayname | users | participant1 | | participant2 | participant2-displayname | users | participant2 | | participant3 | participant3-displayname | users | participant3 | - | participant4 | participant4-displayname | users | participant4 | Scenario: get unmatched mentions in a room for a file shared by link Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 From 105a8157eb79be8be8221f2775ca957693135c42 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 Feb 2026 19:46:42 +0100 Subject: [PATCH 2/2] perf(sharing): Use `getFirstNodeById()` and limit to IUserFolder Signed-off-by: Joas Schilling --- lib/Chat/AutoComplete/SearchPlugin.php | 6 +++++- lib/Controller/FilesIntegrationController.php | 2 +- lib/Files/Util.php | 15 +++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/Chat/AutoComplete/SearchPlugin.php b/lib/Chat/AutoComplete/SearchPlugin.php index dcb303708de..284aa180c51 100644 --- a/lib/Chat/AutoComplete/SearchPlugin.php +++ b/lib/Chat/AutoComplete/SearchPlugin.php @@ -52,7 +52,11 @@ public function setContext(array $context): void { #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { if ($this->room->getObjectType() === 'file') { - $usersWithFileAccess = $this->util->getUsersWithAccessFile($this->room->getObjectId()); + if ($this->userId === null) { + $usersWithFileAccess = $this->util->canGuestsAccessFile($this->room->getObjectId()); + } else { + $usersWithFileAccess = $this->util->getUsersWithAccessFile($this->room->getObjectId(), $this->userId); + } if (!empty($usersWithFileAccess)) { $users = []; foreach ($usersWithFileAccess as $userId) { diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php index c5d276ed1d3..67928369a41 100644 --- a/lib/Controller/FilesIntegrationController.php +++ b/lib/Controller/FilesIntegrationController.php @@ -104,7 +104,7 @@ public function getRoomByFileId(string $fileId): DataResponse { throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user')); } - $users = $this->util->getUsersWithAccessFile($fileId); + $users = $this->util->getUsersWithAccessFile($fileId, $currentUser->getUID()); if (count($users) <= 1 && !$this->util->canGuestsAccessFile($fileId)) { throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user')); } diff --git a/lib/Files/Util.php b/lib/Files/Util.php index 0f98479e5d2..1632b30202e 100644 --- a/lib/Files/Util.php +++ b/lib/Files/Util.php @@ -35,15 +35,15 @@ public function __construct( /** * @return string[] */ - public function getUsersWithAccessFile(string $fileId): array { + public function getUsersWithAccessFile(string $fileId, string $userId): array { if (!isset($this->accessLists[$fileId])) { - $nodes = $this->rootFolder->getById((int)$fileId); + $userFolder = $this->rootFolder->getUserFolder($userId); + $node = $userFolder->getFirstNodeById((int)$fileId); - if (empty($nodes)) { + if ($node === null) { return []; } - $node = array_shift($nodes); $accessList = $this->shareManager->getAccessList($node); $accessList['users'] ??= []; if (!$node->getStorage()->instanceOfStorage(SharedStorage::class)) { @@ -64,18 +64,17 @@ public function getUsersWithAccessFile(string $fileId): array { } public function canUserAccessFile(string $fileId, string $userId): bool { - return \in_array($userId, $this->getUsersWithAccessFile($fileId), true); + return \in_array($userId, $this->getUsersWithAccessFile($fileId, $userId), true); } public function canGuestsAccessFile(string $fileId): bool { if (!isset($this->publicAccessLists[$fileId])) { - $nodes = $this->rootFolder->getById((int)$fileId); + $node = $this->rootFolder->getFirstNodeById((int)$fileId); - if (empty($nodes)) { + if ($node === null) { return false; } - $node = array_shift($nodes); $accessList = $this->shareManager->getAccessList($node, false); $this->publicAccessLists[$fileId] = $accessList['public'] ?? false; }