diff options
-rw-r--r-- | lib/Chat/Notifier.php | 2 | ||||
-rw-r--r-- | lib/Command/Room/TRoomCommand.php | 1 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 15 | ||||
-rw-r--r-- | lib/Files/Listener.php | 8 | ||||
-rw-r--r-- | lib/Manager.php | 4 | ||||
-rw-r--r-- | lib/MatterbridgeManager.php | 1 | ||||
-rw-r--r-- | lib/Service/ParticipantService.php | 11 | ||||
-rw-r--r-- | lib/Service/RoomService.php | 2 | ||||
-rw-r--r-- | tests/php/Service/RoomServiceTest.php | 6 |
9 files changed, 48 insertions, 2 deletions
diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php index 0b5db45eb..e0e959350 100644 --- a/lib/Chat/Notifier.php +++ b/lib/Chat/Notifier.php @@ -341,9 +341,11 @@ class Notifier { // so they can see the room in their room list and // the notification can be parsed and links to an existing room, // where they are a participant of. + $user = $this->userManager->get($userId); $this->participantService->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $userId, + 'displayName' => $user ? $user->getDisplayName() : $userId, ]]); return true; } diff --git a/lib/Command/Room/TRoomCommand.php b/lib/Command/Room/TRoomCommand.php index 68c3d238c..13f6d4efd 100644 --- a/lib/Command/Room/TRoomCommand.php +++ b/lib/Command/Room/TRoomCommand.php @@ -282,6 +282,7 @@ trait TRoomCommand { $participants[] = [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $user->getUID(), + 'displayName' => $user->getDisplayName(), ]; } diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 57a9ff12b..2fa28da53 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -899,6 +899,7 @@ class RoomController extends AEnvironmentAwareController { $participants[] = [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $user->getUID(), + 'displayName' => $user->getDisplayName(), ]; } @@ -954,9 +955,15 @@ class RoomController extends AEnvironmentAwareController { continue; } + $user = $this->userManager->get($this->userId); + if (!$user instanceof IUser) { + continue; + } + $participants[] = [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $member->getUserId(), + 'displayName' => $user->getDisplayName(), ]; } @@ -1248,6 +1255,7 @@ class RoomController extends AEnvironmentAwareController { $participantsToAdd[] = [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $newUser->getUID(), + 'displayName' => $newUser->getDisplayName(), ]; } elseif ($source === 'groups') { $group = $this->groupManager->get($newParticipant); @@ -1260,6 +1268,7 @@ class RoomController extends AEnvironmentAwareController { $participantsToAdd[] = [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $user->getUID(), + 'displayName' => $user->getDisplayName(), ]; } } elseif ($source === 'circles') { @@ -1286,9 +1295,15 @@ class RoomController extends AEnvironmentAwareController { continue; } + $user = $this->userManager->get($this->userId); + if (!$user instanceof IUser) { + continue; + } + $participantsToAdd[] = [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $member->getUserId(), + 'displayName' => $user->getDisplayName(), ]; } } elseif ($source === 'emails') { diff --git a/lib/Files/Listener.php b/lib/Files/Listener.php index f6f2f0e94..c95dd7e77 100644 --- a/lib/Files/Listener.php +++ b/lib/Files/Listener.php @@ -33,6 +33,7 @@ use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; use OCA\Talk\TalkSession; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IUserManager; /** * Custom behaviour for rooms for files. @@ -56,14 +57,18 @@ class Listener { protected $util; /** @var ParticipantService */ protected $participantService; + /** @var IUserManager */ + protected $userManager; /** @var TalkSession */ protected $talkSession; public function __construct(Util $util, ParticipantService $participantService, + IUserManager $userManager, TalkSession $talkSession) { $this->util = $util; $this->participantService = $participantService; + $this->userManager = $userManager; $this->talkSession = $talkSession; } @@ -154,9 +159,12 @@ class Listener { try { $room->getParticipant($userId); } catch (ParticipantNotFoundException $e) { + $user = $this->userManager->get($userId); + $this->participantService->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $userId, + 'displayName' => $user ? $user->getDisplayName() : $userId, ]]); } } diff --git a/lib/Manager.php b/lib/Manager.php index a7c529c3f..fa23f4ade 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -802,9 +802,11 @@ class Manager { $room->setReadOnly(Room::READ_ONLY); $room->setListable(Room::LISTABLE_NONE); + $user = $this->userManager->get($userId); $this->participantService->addUsers($room,[[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $userId, + 'displayName' => $user ? $user->getDisplayName() : $userId, ]]); return $room; } @@ -814,9 +816,11 @@ class Manager { try { $room->getParticipant($userId); } catch (ParticipantNotFoundException $e) { + $user = $this->userManager->get($userId); $this->participantService->addUsers($room,[[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $userId, + 'displayName' => $user ? $user->getDisplayName() : $userId, ]]); } diff --git a/lib/MatterbridgeManager.php b/lib/MatterbridgeManager.php index a7cb2960b..50699b19c 100644 --- a/lib/MatterbridgeManager.php +++ b/lib/MatterbridgeManager.php @@ -309,6 +309,7 @@ class MatterbridgeManager { $this->participantService->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $botUserId, + 'displayName' => $botUser->getDisplayName(), 'participantType' => Participant::USER, ]]); } diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index e32d1f47f..3da1c82be 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -182,6 +182,7 @@ class ParticipantService { $this->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $user->getUID(), + 'displayName' => $user->getDisplayName(), // need to use "USER" here, because "USER_SELF_JOINED" only works for public calls 'participantType' => Participant::USER, ]]); @@ -190,6 +191,7 @@ class ParticipantService { $this->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $user->getUID(), + 'displayName' => $user->getDisplayName(), 'participantType' => Participant::USER_SELF_JOINED, ]]); } else { @@ -279,6 +281,9 @@ class ParticipantService { $attendee->setRoomId($room->getId()); $attendee->setActorType($participant['actorType']); $attendee->setActorId($participant['actorId']); + if (isset($participant['displayName'])) { + $attendee->setDisplayName($participant['displayName']); + } $attendee->setParticipantType($participant['participantType'] ?? Participant::USER); $attendee->setLastReadMessage($lastMessage); $attendee->setReadPrivacy($readPrivacy); @@ -338,10 +343,12 @@ class ParticipantService { $missingUsers = array_diff($users, $participants); foreach ($missingUsers as $userId) { - if ($this->userManager->userExists($userId)) { + $user = $this->userManager->get($userId); + if ($user instanceof IUser) { $this->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, - 'actorId' => $userId, + 'actorId' => $user->getUID(), + 'displayName' => $user->getDisplayName(), 'participantType' => Participant::OWNER, ]]); } diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index afc87851f..5e1000af7 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -68,11 +68,13 @@ class RoomService { [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $actor->getUID(), + 'displayName' => $actor->getDisplayName(), 'participantType' => Participant::OWNER, ], [ 'actorType' => Attendee::ACTOR_USERS, 'actorId' => $targetUser->getUID(), + 'displayName' => $targetUser->getDisplayName(), 'participantType' => Participant::OWNER, ], ]); diff --git a/tests/php/Service/RoomServiceTest.php b/tests/php/Service/RoomServiceTest.php index d223c4c3c..57f771424 100644 --- a/tests/php/Service/RoomServiceTest.php +++ b/tests/php/Service/RoomServiceTest.php @@ -90,9 +90,13 @@ class RoomServiceTest extends TestCase { $user1 = $this->createMock(IUser::class); $user1->method('getUID') ->willReturn('uid1'); + $user1->method('getDisplayName') + ->willReturn('display-1'); $user2 = $this->createMock(IUser::class); $user2->method('getUID') ->willReturn('uid2'); + $user2->method('getDisplayName') + ->willReturn('display-2'); $room = $this->createMock(Room::class); $this->participantService->expects($this->once()) @@ -100,10 +104,12 @@ class RoomServiceTest extends TestCase { ->with($room, [[ 'actorType' => 'users', 'actorId' => 'uid1', + 'displayName' => 'display-1', 'participantType' => Participant::OWNER, ], [ 'actorType' => 'users', 'actorId' => 'uid2', + 'displayName' => 'display-2', 'participantType' => Participant::OWNER, ]]); |