diff options
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Base.php | 3 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 21 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 9 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php | 7 |
4 files changed, 5 insertions, 35 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Base.php b/apps/dav/lib/CalDAV/Activity/Provider/Base.php index 48ed7b8b107..672129a8311 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Base.php @@ -38,9 +38,6 @@ abstract class Base implements IProvider { /** @var IUserManager */ protected $userManager; - /** @var string[] */ - protected $userDisplayNames = []; - /** @var IGroupManager */ protected $groupManager; diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index b00a4f9d6ed..a894b65d756 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -417,7 +417,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription [, $name] = Uri\split($row['principaluri']); $uri = $row['uri'] . '_shared_by_' . $name; - $row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')'; + $row['displayname'] = $row['displayname'] . ' (' . ($this->userManager->getDisplayName($name) ?? ($name ?? '')) . ')'; $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -493,25 +493,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription return array_values($calendars); } - - /** - * @param $uid - * @return string - */ - private function getUserDisplayName($uid) { - if (!isset($this->userDisplayNames[$uid])) { - $user = $this->userManager->get($uid); - - if ($user instanceof IUser) { - $this->userDisplayNames[$uid] = $user->getDisplayName(); - } else { - $this->userDisplayNames[$uid] = $uid; - } - } - - return $this->userDisplayNames[$uid]; - } - /** * @return array */ diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 2c7b06a4396..91610682ef2 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -178,12 +178,7 @@ class IMipPlugin extends SabreIMipPlugin { $recipientName = $iTipMessage->recipientName ?: null; if ($senderName === null || empty(trim($senderName))) { - $user = $this->userManager->get($this->userId); - if ($user) { - // getDisplayName automatically uses the uid - // if no display-name is set - $senderName = $user->getDisplayName(); - } + $sender = $this->userManager->getDisplayName($this->userId) ?? $this->userId; } /** @var VEvent $vevent */ @@ -225,7 +220,7 @@ class IMipPlugin extends SabreIMipPlugin { ]; $fromEMail = Util::getDefaultEmailAddress('invitations-noreply'); - $fromName = $l10n->t('%1$s via %2$s', [$senderName, $this->defaults->getName()]); + $fromName = $l10n->t('%1$s via %2$s', [$senderName ?? $this->userId, $this->defaults->getName()]); $message = $this->mailer->createMessage() ->setFrom([$fromEMail => $fromName]) diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index 0d8076f7aa4..0b64704a87e 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -183,13 +183,10 @@ class IMipPluginTest extends TestCase { $message = $this->_testMessage(); $message->senderName = null; - $user = $this->createMock(IUser::class); - $user->method('getDisplayName')->willReturn('Mr. Wizard'); - $this->userManager->expects($this->once()) - ->method('get') + ->method('getDisplayName') ->with('user123') - ->willReturn($user); + ->willReturn('Mr. Wizard'); $this->_expectSend(); $this->plugin->schedule($message); |