summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-16 13:16:10 +0200
committerJoas Schilling <coding@schilljs.com>2022-08-17 10:31:14 +0200
commit36f511d19844c1d4f661ecdf9ac01ce7d90916b8 (patch)
tree1efd08914bb741ddf046078faeb7c020bc411bef /lib
parent197c14398107c30aac46c08cce4eae8a1e1a672d (diff)
Add display name cache to SystemMessage
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/MessageParser.php3
-rw-r--r--lib/Chat/Parser/SystemMessage.php7
-rw-r--r--lib/Manager.php2
3 files changed, 5 insertions, 7 deletions
diff --git a/lib/Chat/MessageParser.php b/lib/Chat/MessageParser.php
index ef011bffc..e64287c48 100644
--- a/lib/Chat/MessageParser.php
+++ b/lib/Chat/MessageParser.php
@@ -34,7 +34,6 @@ use OCA\Talk\Room;
use OCP\Comments\IComment;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IL10N;
-use OCP\IUser;
use OCP\IUserManager;
/**
@@ -79,7 +78,7 @@ class MessageParser {
$actorId = $comment->getActorId();
$displayName = '';
if ($comment->getActorType() === Attendee::ACTOR_USERS) {
- $displayName = $this->userManager->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 4c1230f0c..51666142d 100644
--- a/lib/Chat/Parser/SystemMessage.php
+++ b/lib/Chat/Parser/SystemMessage.php
@@ -44,7 +44,6 @@ use OCP\IGroupManager;
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 @@ class SystemMessage {
}
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 65a6167c6..f72fc5c5b 100644
--- a/lib/Manager.php
+++ b/lib/Manager.php
@@ -990,7 +990,7 @@ class Manager {
foreach ($users as $participantId) {
if ($participantId !== $userId) {
- $otherParticipant = $this->userManager->getDisplayName($participantId);
+ $otherParticipant = $this->userManager->getDisplayName($participantId) ?? $participantId;
} else {
$userIsParticipant = true;
}