summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-18 09:58:22 +0200
committerJoas Schilling <coding@schilljs.com>2022-08-19 12:06:21 +0200
commit1c29d7714f899b44507306dd4b3b05e0c4e02dfc (patch)
tree13676e5184cfbe968cc04662df14b839cb344577 /lib
parentfa2dfc51e6d4f75950f777bb7b2d607004c1f2f7 (diff)
Use user displayname cache in notification rendering
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/Notifier.php4
-rw-r--r--lib/Notification/Notifier.php26
2 files changed, 15 insertions, 15 deletions
diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php
index 5874d05bf..3f048c056 100644
--- a/lib/Chat/Notifier.php
+++ b/lib/Chat/Notifier.php
@@ -467,11 +467,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);
+ $userDisplayName = $this->userManager->getDisplayName($userId);
$this->participantService->addUsers($room, [[
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $userId,
- 'displayName' => $user ? $user->getDisplayName() : $userId,
+ 'displayName' => $userDisplayName ?? $userId,
]]);
return true;
}
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php
index 68af32113..77dbcfaf5 100644
--- a/lib/Notification/Notifier.php
+++ b/lib/Notification/Notifier.php
@@ -332,13 +332,13 @@ class Notifier implements INotifier {
$isGuest = false;
if ($subjectParameters['userType'] === 'users') {
$userId = $subjectParameters['userId'];
- $user = $this->userManager->get($userId);
+ $userDisplayName = $this->userManager->getDisplayName($userId);
- if ($user instanceof IUser) {
+ if ($userDisplayName !== null) {
$richSubjectUser = [
'type' => 'user',
'id' => $userId,
- 'name' => $user->getDisplayName(),
+ 'name' => $userDisplayName,
];
}
} else {
@@ -559,8 +559,8 @@ class Notifier implements INotifier {
$parameters = $notification->getSubjectParameters();
$uid = $parameters['actorId'] ?? $parameters[0];
- $user = $this->userManager->get($uid);
- if (!$user instanceof IUser) {
+ $userDisplayName = $this->userManager->getDisplayName($uid);
+ if ($userDisplayName === null) {
throw new AlreadyProcessedException();
}
@@ -574,13 +574,13 @@ class Notifier implements INotifier {
}
$notification
- ->setParsedSubject(str_replace('{user}', $user->getDisplayName(), $subject))
+ ->setParsedSubject(str_replace('{user}', $userDisplayName, $subject))
->setRichSubject(
$subject, [
'user' => [
'type' => 'user',
'id' => $uid,
- 'name' => $user->getDisplayName(),
+ 'name' => $userDisplayName,
],
'call' => [
'type' => 'call',
@@ -599,13 +599,13 @@ class Notifier implements INotifier {
}
$notification
- ->setParsedSubject(str_replace(['{user}', '{call}'], [$user->getDisplayName(), $roomName], $subject))
+ ->setParsedSubject(str_replace(['{user}', '{call}'], [$userDisplayName, $roomName], $subject))
->setRichSubject(
$subject, [
'user' => [
'type' => 'user',
'id' => $uid,
- 'name' => $user->getDisplayName(),
+ 'name' => $userDisplayName,
],
'call' => [
'type' => 'call',
@@ -639,8 +639,8 @@ class Notifier implements INotifier {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
$parameters = $notification->getSubjectParameters();
$calleeId = $parameters['callee'];
- $user = $this->userManager->get($calleeId);
- if ($user instanceof IUser) {
+ $userDisplayName = $this->userManager->getDisplayName($calleeId);
+ if ($userDisplayName !== null) {
if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Answer call'));
$subject = $l->t('{user} would like to talk with you');
@@ -650,13 +650,13 @@ class Notifier implements INotifier {
}
$notification
- ->setParsedSubject(str_replace('{user}', $user->getDisplayName(), $subject))
+ ->setParsedSubject(str_replace('{user}', $userDisplayName, $subject))
->setRichSubject(
$subject, [
'user' => [
'type' => 'user',
'id' => $calleeId,
- 'name' => $user->getDisplayName(),
+ 'name' => $userDisplayName,
],
'call' => [
'type' => 'call',