diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 4f060eabf2a33ed789cddd912d79ac75e75e06f7..3b90a6d99b4f1f850f5f6951d44c3105811fc58a 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -16,6 +16,7 @@ use OCA\Calendar\Middleware\InvitationMiddleware; use OCA\Calendar\Notification\Notifier; use OCA\Calendar\Profile\AppointmentsAction; use OCA\Calendar\Reference\ReferenceProvider; +use OCA\DAV\Connector\Sabre\Principal; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -65,6 +66,7 @@ class Application extends App implements IBootstrap { $c->get(LoggerInterface::class), $c->get(IUserManager::class), $c->get(L10NFactory::class), + $c->get(Principal::class), ); }); @@ -89,6 +91,7 @@ class Application extends App implements IBootstrap { $c->get(LoggerInterface::class), $c->get(IUserManager::class), $c->get(L10NFactory::class), + $c->get(Principal::class), ); }); diff --git a/lib/Middleware/InvitationMiddleware.php b/lib/Middleware/InvitationMiddleware.php index 2c2027fa36b04aa0ff83a560308ed1487a994c2e..1aedaeab7de2ae58d281319469d0dfdaf53df893 100644 --- a/lib/Middleware/InvitationMiddleware.php +++ b/lib/Middleware/InvitationMiddleware.php @@ -3,6 +3,7 @@ namespace OCA\Calendar\Middleware; use OCA\Calendar\Controller\InvitationMaybeController; +use OCA\DAV\Connector\Sabre\Principal; use OCA\Dav\Controller\InvitationResponseController; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; @@ -34,6 +35,7 @@ class InvitationMiddleware extends Middleware { LoggerInterface $logger, IUserManager $iusermanager, IFactory $languageFactory, + private Principal $principalBackend, ) { $this->request = $request; $this->config = $config; @@ -75,17 +77,27 @@ class InvitationMiddleware extends Middleware { $uid = $row['uid']; $sender = substr($row['attendee'], 7); - $recipient = substr($row['organizer'], 7); - + + $organizer = $row['organizer']; + $recipient = substr($organizer, 7); + + $principalUriOfOrganizer = $this->principalBackend->findByUri($organizer, 'principals/users'); + if ($principalUriOfOrganizer === null) { + $this->logger->warning('Principal URI not found for organizer', ['organizer' => $organizer]); + return $response; + } + $query2 = $this->db->getQueryBuilder(); $query2 - ->select('*') - ->from('calendarobjects') + ->select('co.*') + ->from('calendarobjects', 'co') + ->join('co', 'calendars', 'c', $query2->expr()->eq('co.calendarid', 'c.id')) ->where( - $query + $query2 ->expr() ->eq('uid', $query2->createNamedParameter($uid)) - ); + )->andWhere($query2->expr()->eq('c.principaluri', $query2->createNamedParameter($principalUriOfOrganizer))); + $stmt2 = $query2->execute(); $row2 = $stmt2->fetch(\PDO::FETCH_ASSOC); $calendarobjectid = $row2['id']; @@ -150,6 +162,8 @@ class InvitationMiddleware extends Middleware { $organizername = $recipient; } + $defaultVal = ''; + if ($methodName === 'tentative') { $meetingTitle = $this->l10n->t('Invitation Tentatively Accepted: %s', [$SUMMARY]);