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
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-09-02 16:57:25 +0300
committerJoas Schilling <coding@schilljs.com>2021-09-14 16:34:12 +0300
commita95bf0820d4d34f9eaa749ec3ca020acc635355f (patch)
tree3d2d05928c63beadce48ab052add5936125ddf97 /lib
parent5ddc878c183d66671a6f15e464828ccff79fba8a (diff)
Unify handling of deleted users
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/Parser/SystemMessage.php35
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php
index ad63f4f7e..8c69a2140 100644
--- a/lib/Chat/Parser/SystemMessage.php
+++ b/lib/Chat/Parser/SystemMessage.php
@@ -68,7 +68,9 @@ class SystemMessage {
/** @var IL10N */
protected $l;
- /** @var string[] */
+ /**
+ * @psalm-var array<array-key, null|string>
+ */
protected $displayNames = [];
/** @var string[] */
protected $groupNames = [];
@@ -584,7 +586,19 @@ class SystemMessage {
protected function getUser(string $uid): array {
if (!isset($this->displayNames[$uid])) {
- $this->displayNames[$uid] = $this->getDisplayName($uid);
+ try {
+ $this->displayNames[$uid] = $this->getDisplayName($uid);
+ } catch (ParticipantNotFoundException $e) {
+ $this->displayNames[$uid] = null;
+ }
+ }
+
+ if ($this->displayNames[$uid] === null) {
+ return [
+ 'type' => 'highlight',
+ 'id' => 'deleted_user',
+ 'name' => $this->l->t('Deleted user'),
+ ];
}
return [
@@ -594,6 +608,15 @@ class SystemMessage {
];
}
+ protected function getDisplayName(string $uid): string {
+ $user = $this->userManager->get($uid);
+ if ($user instanceof IUser) {
+ return $user->getDisplayName();
+ }
+
+ throw new ParticipantNotFoundException();
+ }
+
protected function getGroup(string $gid): array {
if (!isset($this->groupNames[$gid])) {
$this->groupNames[$gid] = $this->getDisplayNameGroup($gid);
@@ -627,14 +650,6 @@ class SystemMessage {
];
}
- protected function getDisplayName(string $uid): string {
- $user = $this->userManager->get($uid);
- if ($user instanceof IUser) {
- return $user->getDisplayName();
- }
- return $uid;
- }
-
protected function getDisplayNameGroup(string $gid): string {
$group = $this->groupManager->get($gid);
if ($group instanceof IGroup) {