mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix(caldav): Use userSession instead of userId
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
This commit is contained in:
parent
9859a44908
commit
f44b73e2db
2 changed files with 16 additions and 21 deletions
|
|
@ -41,7 +41,7 @@ use OCA\DAV\CalDAV\EventComparisonService;
|
|||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Defaults;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Mail\IMailer;
|
||||
use OCP\Util;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -69,13 +69,12 @@ use Sabre\VObject\Reader;
|
|||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class IMipPlugin extends SabreIMipPlugin {
|
||||
private ?string $userId;
|
||||
private IUserSession $userSession;
|
||||
private IConfig $config;
|
||||
private IMailer $mailer;
|
||||
private LoggerInterface $logger;
|
||||
private ITimeFactory $timeFactory;
|
||||
private Defaults $defaults;
|
||||
private IUserManager $userManager;
|
||||
private ?VCalendar $vCalendar = null;
|
||||
private IMipService $imipService;
|
||||
public const MAX_DATE = '2038-01-01';
|
||||
|
|
@ -90,18 +89,16 @@ class IMipPlugin extends SabreIMipPlugin {
|
|||
LoggerInterface $logger,
|
||||
ITimeFactory $timeFactory,
|
||||
Defaults $defaults,
|
||||
IUserManager $userManager,
|
||||
$userId,
|
||||
IUserSession $userSession,
|
||||
IMipService $imipService,
|
||||
EventComparisonService $eventComparisonService) {
|
||||
parent::__construct('');
|
||||
$this->userId = $userId;
|
||||
$this->userSession = $userSession;
|
||||
$this->config = $config;
|
||||
$this->mailer = $mailer;
|
||||
$this->logger = $logger;
|
||||
$this->timeFactory = $timeFactory;
|
||||
$this->defaults = $defaults;
|
||||
$this->userManager = $userManager;
|
||||
$this->imipService = $imipService;
|
||||
$this->eventComparisonService = $eventComparisonService;
|
||||
}
|
||||
|
|
@ -206,17 +203,16 @@ class IMipPlugin extends SabreIMipPlugin {
|
|||
$this->imipService->setL10n($attendee);
|
||||
|
||||
// Build the sender name.
|
||||
// Due to a bug in sabre, the senderName property for an iTIP message
|
||||
// can actually also be a VObject Property
|
||||
/** @var Parameter|string|null $senderName */
|
||||
$senderName = $iTipMessage->senderName ?: null;
|
||||
if($senderName instanceof Parameter) {
|
||||
$senderName = $senderName->getValue() ?? null;
|
||||
// Due to a bug in sabre, the senderName property for an iTIP message can actually also be a VObject Property
|
||||
// If the iTIP message senderName is null or empty use the user session name as the senderName
|
||||
if (($iTipMessage->senderName instanceof Parameter) && !empty(trim($iTipMessage->senderName->getValue()))) {
|
||||
$senderName = $iTipMessage->senderName->getValue();
|
||||
}
|
||||
|
||||
// Try to get the sender name from the current user id if available.
|
||||
if ($this->userId !== null && ($senderName === null || empty(trim($senderName)))) {
|
||||
$senderName = $this->userManager->getDisplayName($this->userId);
|
||||
elseif (is_string($iTipMessage->senderName) && !empty(trim($iTipMessage->senderName))) {
|
||||
$senderName = $iTipMessage->senderName;
|
||||
}
|
||||
else {
|
||||
$senderName = $this->userSession->getUser()->getDisplayName();
|
||||
}
|
||||
|
||||
$sender = substr($iTipMessage->sender, 7);
|
||||
|
|
|
|||
|
|
@ -304,13 +304,12 @@ class Server {
|
|||
));
|
||||
if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
|
||||
$this->server->addPlugin(new IMipPlugin(
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getMailer(),
|
||||
\OC::$server->get(\OCP\IConfig::class),
|
||||
\OC::$server->get(\OCP\Mail\IMailer::class),
|
||||
\OC::$server->get(LoggerInterface::class),
|
||||
\OC::$server->get(\OCP\AppFramework\Utility\ITimeFactory::class),
|
||||
\OC::$server->get(\OCP\Defaults::class),
|
||||
\OC::$server->get(\OCP\IUserManager::class),
|
||||
$user->getUid(),
|
||||
$userSession,
|
||||
\OC::$server->get(\OCA\DAV\CalDAV\Schedule\IMipService::class),
|
||||
\OC::$server->get(\OCA\DAV\CalDAV\EventComparisonService::class)
|
||||
));
|
||||
|
|
|
|||
Loading…
Reference in a new issue