mirror of
https://github.com/nextcloud/server.git
synced 2026-03-02 21:41:12 -05:00
Switch to DisplayNameCache for CalDAV
Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
parent
bfb764b5f3
commit
e5c290bb7f
4 changed files with 5 additions and 35 deletions
|
|
@ -38,9 +38,6 @@ abstract class Base implements IProvider {
|
|||
/** @var IUserManager */
|
||||
protected $userManager;
|
||||
|
||||
/** @var string[] */
|
||||
protected $userDisplayNames = [];
|
||||
|
||||
/** @var IGroupManager */
|
||||
protected $groupManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue