aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/User/LazyUser.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/User/LazyUser.php')
-rw-r--r--lib/private/User/LazyUser.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php
index 096578b8f37..c36ff86eff4 100644
--- a/lib/private/User/LazyUser.php
+++ b/lib/private/User/LazyUser.php
@@ -30,16 +30,26 @@ use OCP\UserInterface;
class LazyUser implements IUser {
private ?IUser $user = null;
private string $uid;
+ private ?string $displayName;
private IUserManager $userManager;
+ private ?UserInterface $backend;
- public function __construct(string $uid, IUserManager $userManager) {
+ public function __construct(string $uid, IUserManager $userManager, ?string $displayName = null, ?UserInterface $backend = null) {
$this->uid = $uid;
$this->userManager = $userManager;
+ $this->displayName = $displayName;
+ $this->backend = $backend;
}
private function getUser(): IUser {
if ($this->user === null) {
- $this->user = $this->userManager->get($this->uid);
+ if ($this->backend) {
+ /** @var \OC\User\Manager $manager */
+ $manager = $this->userManager;
+ $this->user = $manager->getUserObject($this->uid, $this->backend);
+ } else {
+ $this->user = $this->userManager->get($this->uid);
+ }
}
/** @var IUser */
$user = $this->user;
@@ -51,7 +61,11 @@ class LazyUser implements IUser {
}
public function getDisplayName() {
- return $this->userManager->getDisplayName($this->uid) ?? $this->uid;
+ if ($this->displayName) {
+ return $this->displayName;
+ }
+
+ return $this->userManager->getDisplayName($this->uid);
}
public function setDisplayName($displayName) {