Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions lib/Chat/MessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
use OCP\Comments\IComment;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;

/**
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 3 additions & 8 deletions tests/php/Chat/Parser/SystemMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down