diff --git a/composer.lock b/composer.lock index 524f88e1685..11614843aa4 100644 --- a/composer.lock +++ b/composer.lock @@ -242,12 +242,12 @@ "source": { "type": "git", "url": "https://github.com/ChristophWurst/nextcloud_composer.git", - "reference": "577103cb24552d134a6338014fe665cabfd9c2c8" + "reference": "433f70a9ddfece0233927997ae5ff38070fc1fcc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/577103cb24552d134a6338014fe665cabfd9c2c8", - "reference": "577103cb24552d134a6338014fe665cabfd9c2c8", + "url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/433f70a9ddfece0233927997ae5ff38070fc1fcc", + "reference": "433f70a9ddfece0233927997ae5ff38070fc1fcc", "shasum": "" }, "require": { @@ -278,7 +278,7 @@ "issues": "https://github.com/ChristophWurst/nextcloud_composer/issues", "source": "https://github.com/ChristophWurst/nextcloud_composer/tree/master" }, - "time": "2022-08-09T02:21:50+00:00" + "time": "2022-08-17T02:31:52+00:00" }, { "name": "composer/package-versions-deprecated", diff --git a/lib/Chat/MessageParser.php b/lib/Chat/MessageParser.php index 5428b9f7c9e..e64287c4841 100644 --- a/lib/Chat/MessageParser.php +++ b/lib/Chat/MessageParser.php @@ -34,7 +34,6 @@ use OCP\Comments\IComment; use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; -use OCP\IUser; use OCP\IUserManager; /** @@ -79,8 +78,7 @@ protected function setActor(Message $message): void { $actorId = $comment->getActorId(); $displayName = ''; if ($comment->getActorType() === Attendee::ACTOR_USERS) { - $user = $this->userManager->get($comment->getActorId()); - $displayName = $user instanceof IUser ? $user->getDisplayName() : $comment->getActorId(); + $displayName = $this->userManager->getDisplayName($comment->getActorId()) ?? $comment->getActorId(); } elseif ($comment->getActorType() === Attendee::ACTOR_BRIDGED) { $displayName = $comment->getActorId(); $actorId = MatterbridgeManager::BRIDGE_BOT_USERID; diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 4c1230f0cef..51666142d04 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -44,7 +44,6 @@ use OCP\IL10N; use OCP\IPreview as IPreviewManager; use OCP\IURLGenerator; -use OCP\IUser; use OCP\IUserManager; use OCP\Server; use OCP\Share\Exceptions\ShareNotFound; @@ -698,9 +697,9 @@ protected function getRemoteUser(string $federationId): array { } protected function getDisplayName(string $uid): string { - $user = $this->userManager->get($uid); - if ($user instanceof IUser) { - return $user->getDisplayName(); + $userName = $this->userManager->getDisplayName($uid); + if ($userName !== null) { + return $userName; } throw new ParticipantNotFoundException(); diff --git a/lib/Manager.php b/lib/Manager.php index 5acf16c2cc1..f72fc5c5b1b 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -990,8 +990,7 @@ public function resolveRoomDisplayName(Room $room, string $userId): string { foreach ($users as $participantId) { if ($participantId !== $userId) { - $user = $this->userManager->get($participantId); - $otherParticipant = $user instanceof IUser ? $user->getDisplayName() : $participantId; + $otherParticipant = $this->userManager->getDisplayName($participantId) ?? $participantId; } else { $userIsParticipant = true; } diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index ad9daae63da..1ffa7d5d109 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -44,7 +44,6 @@ use OCP\IL10N; use OCP\IPreview as IPreviewManager; use OCP\IURLGenerator; -use OCP\IUser; use OCP\IUserManager; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IShare; @@ -948,17 +947,13 @@ public function testGetDisplayName(string $uid, bool $validUser, string $name) { $parser = $this->getParser(); if ($validUser) { - $user = $this->createMock(IUser::class); - $user->expects($this->once()) - ->method('getDisplayName') - ->willReturn($name); $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with($uid) - ->willReturn($user); + ->willReturn($name); } else { $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with($uid) ->willReturn(null); $this->expectException(ParticipantNotFoundException::class);