Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-02-11 22:12:27 +0300
committerJoas Schilling <coding@schilljs.com>2021-02-12 09:34:35 +0300
commit383ca5fd4c0fa9ddfd0f1c023b9b25ec1f67727e (patch)
treeb7fb62924f85612214b8dfcc8fa9f1bbfed42a31
parent1cfb072c6620785270b3a8c9b61a230ce23b1a7d (diff)
Populate the display name when adding logged in users
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Chat/Notifier.php2
-rw-r--r--lib/Command/Room/TRoomCommand.php1
-rw-r--r--lib/Controller/RoomController.php15
-rw-r--r--lib/Files/Listener.php8
-rw-r--r--lib/Manager.php4
-rw-r--r--lib/MatterbridgeManager.php1
-rw-r--r--lib/Service/ParticipantService.php11
-rw-r--r--lib/Service/RoomService.php2
-rw-r--r--tests/php/Service/RoomServiceTest.php6
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,
]]);