From 3d5569c7f555e7c2d1102c7b66abd4dc387ba681 Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Fri, 8 Nov 2024 10:14:24 -0500 Subject: [PATCH 1/2] fix: use autocomplete api to respect settings Signed-off-by: Elizabeth Danzberger --- lib/Controller/MentionController.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Controller/MentionController.php b/lib/Controller/MentionController.php index 441af7d15f..998107fda6 100644 --- a/lib/Controller/MentionController.php +++ b/lib/Controller/MentionController.php @@ -14,10 +14,12 @@ use OCP\AppFramework\Http\Attribute\UserRateLimit; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Collaboration\Collaborators\ISearch; use OCP\Files\IRootFolder; use OCP\IRequest; use OCP\IUserManager; use OCP\Notification\IManager; +use OCP\Share\IShare; class MentionController extends Controller { public function __construct( @@ -27,6 +29,7 @@ public function __construct( private IManager $manager, private ITimeFactory $timeFactory, private IUserManager $userManager, + private ISearch $collaboratorSearch, private ?string $userId, ) { parent::__construct($appName, $request); @@ -41,22 +44,21 @@ public function mention(int $fileId, string $mention): DataResponse { return new DataResponse(['message' => 'File not found for current user'], Http::STATUS_NOT_FOUND); } - // Reverse the array of users to pop off the first user later - $userResults = array_reverse($this->userManager->searchDisplayName($mention, 1)); - if (count($userResults) < 1) { + [$searchResults, ] = $this->collaboratorSearch->search($mention, [IShare::TYPE_USER], false, 1, 0); + $matchedUsers = $searchResults['exact']['users']; + if (count($matchedUsers) < 1) { return new DataResponse([], Http::STATUS_NOT_FOUND); } - - // Get the first user returned in the array - $user = array_pop($userResults); - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); + + $user = array_pop($matchedUsers); + $userFolder = $this->rootFolder->getUserFolder($user['value']['shareWith']); $file = $userFolder->getFirstNodeById($fileId); if ($file === null) { return new DataResponse(['message' => 'File not found for mentioned user'], Http::STATUS_NOT_FOUND); } $notification = $this->manager->createNotification(); - $notification->setUser($user->getUID()) + $notification->setUser($user['value']['shareWith']) ->setApp(Application::APPNAME) ->setSubject(Notifier::TYPE_MENTIONED, [ Notifier::SUBJECT_MENTIONED_SOURCE_USER => $this->userId, From 1d4c813c2ff18f7f932257ae2c8de39902858521 Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Fri, 22 Nov 2024 13:08:47 -0500 Subject: [PATCH 2/2] feat: pass user label to collabora via postmessage Signed-off-by: Elizabeth Danzberger --- src/mixins/uiMention.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mixins/uiMention.js b/src/mixins/uiMention.js index 95f6645f6e..de83aa5ab2 100644 --- a/src/mixins/uiMention.js +++ b/src/mixins/uiMention.js @@ -27,7 +27,8 @@ export default { const list = users.map((user) => { const profile = window.location.protocol + '//' + getNextcloudUrl() + '/index.php/u/' + user.id return { - username: user.label, + label: user.label, + username: user.id, profile, } })