From 1749359485891605649b19224fd37d76874c3472 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Tue, 8 Nov 2022 16:30:55 +0530 Subject: [PATCH 01/11] new patch for multiple email notification fix --- Dockerfile | 1 + patches/022-multiplenotification.patch | 871 +++++++++++++++++++++++++ 2 files changed, 872 insertions(+) create mode 100644 patches/022-multiplenotification.patch diff --git a/Dockerfile b/Dockerfile index d6abb495..505f1197 100644 --- a/Dockerfile +++ b/Dockerfile @@ -136,6 +136,7 @@ RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-o RUN patch -u ${BASE_DIR}/apps/settings/lib/Sections/Personal/Groupware.php -i ${TMP_PATCH_DIR}/019-groupware.patch RUN patch -u ${BASE_DIR}/lib/private/Notification/Manager.php -i ${TMP_PATCH_DIR}/020-fairuse-notification-fix.patch RUN patch -u ${BASE_DIR}/apps/files/js/files.js -i ${TMP_PATCH_DIR}/021-repeated-storage-dialog-fix.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch RUN rm -rf ${TMP_PATCH_DIR} # show reset pwd page with a query param diff --git a/patches/022-multiplenotification.patch b/patches/022-multiplenotification.patch new file mode 100644 index 00000000..b38af98c --- /dev/null +++ b/patches/022-multiplenotification.patch @@ -0,0 +1,871 @@ +--- ./apps/dav/lib/Connector/Sabre/Principal.php 2022-09-06 21:39:44.155827300 +0530 ++++ ./apps/dav/lib/Connector/Sabre/Principal-new.php 2022-11-08 15:51:57.600075100 +0530 +@@ -41,6 +41,9 @@ + use OCA\Circles\Exceptions\CircleNotFoundException; + use OCA\DAV\CalDAV\Proxy\ProxyMapper; + use OCA\DAV\Traits\PrincipalProxyTrait; ++use OCP\Accounts\IAccountManager; ++use OCP\Accounts\IAccountProperty; ++use OCP\Accounts\PropertyDoesNotExistException; + use OCP\App\IAppManager; + use OCP\AppFramework\QueryException; + use OCP\Constants; +@@ -64,6 +67,9 @@ + /** @var IGroupManager */ + private $groupManager; + ++ /** @var IAccountManager */ ++ private $accountManager; ++ + /** @var IShareManager */ + private $shareManager; + +@@ -95,6 +101,7 @@ + + public function __construct(IUserManager $userManager, + IGroupManager $groupManager, ++ IAccountManager $accountManager, + IShareManager $shareManager, + IUserSession $userSession, + IAppManager $appManager, +@@ -105,6 +112,7 @@ + string $principalPrefix = 'principals/users/') { + $this->userManager = $userManager; + $this->groupManager = $groupManager; ++ $this->accountManager = $accountManager; + $this->shareManager = $shareManager; + $this->userSession = $userSession; + $this->appManager = $appManager; +@@ -506,6 +514,7 @@ + /** + * @param IUser $user + * @return array ++ * @throws PropertyDoesNotExistException + */ + protected function userToPrincipal($user) { + $userId = $user->getUID(); +@@ -517,11 +526,18 @@ + '{http://nextcloud.com/ns}language' => $this->languageFactory->getUserLanguage($user), + ]; + ++ $account = $this->accountManager->getAccount($user); ++ $alternativeEmails = array_map(fn (IAccountProperty $property) => 'mailto:' . $property->getValue(), $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties()); ++ + $email = $user->getSystemEMailAddress(); + if (!empty($email)) { + $principal['{http://sabredav.org/ns}email-address'] = $email; + } + ++ if (!empty($alternativeEmails)) { ++ $principal['{DAV:}alternate-URI-set'] = $alternativeEmails; ++ } ++ + return $principal; + } + +@@ -591,4 +607,44 @@ + + return []; + } +-} ++ ++ /** ++ * Get all email addresses associated to a principal. ++ * ++ * @param array $principal Data from getPrincipal*() ++ * @return string[] All email addresses without the mailto: prefix ++ */ ++ public function getEmailAddressesOfPrincipal(array $principal): array { ++ $emailAddresses = []; ++ ++ if (($primaryAddress = $principal['{http://sabredav.org/ns}email-address'])) { ++ $emailAddresses[] = $primaryAddress; ++ } ++ ++ if (isset($principal['{DAV:}alternate-URI-set'])) { ++ foreach ($principal['{DAV:}alternate-URI-set'] as $address) { ++ if (str_starts_with($address, 'mailto:')) { ++ $emailAddresses[] = substr($address, 7); ++ } ++ } ++ } ++ ++ if (isset($principal['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set'])) { ++ foreach ($principal['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set'] as $address) { ++ if (str_starts_with($address, 'mailto:')) { ++ $emailAddresses[] = substr($address, 7); ++ } ++ } ++ } ++ ++ if (isset($principal['{http://calendarserver.org/ns/}email-address-set'])) { ++ foreach ($principal['{http://calendarserver.org/ns/}email-address-set'] as $address) { ++ if (str_starts_with($address, 'mailto:')) { ++ $emailAddresses[] = substr($address, 7); ++ } ++ } ++ } ++ ++ return array_values(array_unique($emailAddresses)); ++ } ++} +\ No newline at end of file + +--- ./apps/dav/lib/CalDAV/Schedule/Plugin.php 2022-09-06 21:39:44.145827300 +0530 ++++ ./apps/dav/lib/CalDAV/Schedule/Plugin-new.php 2022-11-08 15:49:50.620075100 +0530 +@@ -9,6 +9,7 @@ + * @author Joas Schilling + * @author Roeland Jago Douma + * @author Thomas Citharel ++ * @author Richard Steinmetz + * + * @license GNU AGPL version 3 or any later version + * +@@ -30,6 +31,7 @@ + + use DateTimeZone; + use OCA\DAV\CalDAV\CalDavBackend; ++use OCA\DAV\CalDAV\Calendar; + use OCA\DAV\CalDAV\CalendarHome; + use OCP\IConfig; + use Sabre\CalDAV\ICalendar; +@@ -45,6 +47,7 @@ + use Sabre\VObject\Component\VCalendar; + use Sabre\VObject\Component\VEvent; + use Sabre\VObject\DateTimeParser; ++use Sabre\VObject\Document; + use Sabre\VObject\FreeBusyGenerator; + use Sabre\VObject\ITip; + use Sabre\VObject\Parameter; +@@ -163,6 +166,14 @@ + * @inheritDoc + */ + public function scheduleLocalDelivery(ITip\Message $iTipMessage):void { ++ /** @var Component|null $vevent */ ++ $vevent = $iTipMessage->message->VEVENT ?? null; ++ ++ // Strip VALARMs from incoming VEVENT ++ if ($vevent && isset($vevent->VALARM)) { ++ $vevent->remove('VALARM'); ++ } ++ + parent::scheduleLocalDelivery($iTipMessage); + + // We only care when the message was successfully delivered locally +@@ -178,7 +189,7 @@ + + // If parent::scheduleLocalDelivery set scheduleStatus to 1.2, + // it means that it was successfully delivered locally. +- // Meaning that the ACL plugin is loaded and that a principial ++ // Meaning that the ACL plugin is loaded and that a principal + // exists for the given recipient id, no need to double check + /** @var \Sabre\DAVACL\Plugin $aclPlugin */ + $aclPlugin = $this->server->getPlugin('acl'); +@@ -199,18 +210,10 @@ + return; + } + +- if (!isset($iTipMessage->message)) { ++ if (!$vevent) { + return; + } + +- $vcalendar = $iTipMessage->message; +- if (!isset($vcalendar->VEVENT)) { +- return; +- } +- +- /** @var Component $vevent */ +- $vevent = $vcalendar->VEVENT; +- + // We don't support autoresponses for recurrencing events for now + if (isset($vevent->RRULE) || isset($vevent->RDATE)) { + return; +@@ -299,12 +302,14 @@ + return null; + } + ++ $isResourceOrRoom = strpos($principalUrl, 'principals/calendar-resources') === 0 || ++ strpos($principalUrl, 'principals/calendar-rooms') === 0; ++ + if (strpos($principalUrl, 'principals/users') === 0) { + [, $userId] = split($principalUrl); + $uri = $this->config->getUserValue($userId, 'dav', 'defaultCalendar', CalDavBackend::PERSONAL_CALENDAR_URI); + $displayName = CalDavBackend::PERSONAL_CALENDAR_NAME; +- } elseif (strpos($principalUrl, 'principals/calendar-resources') === 0 || +- strpos($principalUrl, 'principals/calendar-rooms') === 0) { ++ } elseif ($isResourceOrRoom) { + $uri = CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI; + $displayName = CalDavBackend::RESOURCE_BOOKING_CALENDAR_NAME; + } else { +@@ -316,9 +321,40 @@ + /** @var CalendarHome $calendarHome */ + $calendarHome = $this->server->tree->getNodeForPath($calendarHomePath); + if (!$calendarHome->childExists($uri)) { +- $calendarHome->getCalDAVBackend()->createCalendar($principalUrl, $uri, [ +- '{DAV:}displayname' => $displayName, +- ]); ++ // If the default calendar doesn't exist ++ if ($isResourceOrRoom) { ++ $calendarHome->getCalDAVBackend()->createCalendar($principalUrl, $uri, [ ++ '{DAV:}displayname' => $displayName, ++ ]); ++ } else { ++ // And we're not handling scheduling on resource/room booking ++ $userCalendars = []; ++ /** ++ * If the default calendar of the user isn't set and the ++ * fallback doesn't match any of the user's calendar ++ * try to find the first "personal" calendar we can write to ++ * instead of creating a new one. ++ * A appropriate personal calendar to receive invites: ++ * - isn't a calendar subscription ++ * - user can write to it (no virtual/3rd-party calendars) ++ * - calendar isn't a share ++ */ ++ foreach ($calendarHome->getChildren() as $node) { ++ if ($node instanceof Calendar && !$node->isSubscription() && $node->canWrite() && !$node->isShared() && !$node->isDeleted()) { ++ $userCalendars[] = $node; ++ } ++ } ++ ++ if (count($userCalendars) > 0) { ++ // Calendar backend returns calendar by calendarorder property ++ $uri = $userCalendars[0]->getName(); ++ } else { ++ // Otherwise if we have really nothing, create a new calendar ++ $calendarHome->getCalDAVBackend()->createCalendar($principalUrl, $uri, [ ++ '{DAV:}displayname' => $displayName, ++ ]); ++ } ++ } + } + + $result = $this->server->getPropertiesForPath($calendarHomePath . '/' . $uri, [], 1); +@@ -533,7 +569,7 @@ + } + + // If more than one Free-Busy property was returned, it means that an event +- // starts or ends inside this time-range, so it's not availabe and we return false ++ // starts or ends inside this time-range, so it's not available and we return false + if (count($freeBusyProperties) > 1) { + return false; + } +@@ -564,4 +600,4 @@ + + return $email; + } +-} ++} +\ No newline at end of file + +--- ./apps/dav/lib/CalDAV/Reminder/ReminderService.php 2022-09-06 21:39:44.135827300 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/ReminderService-new.php 2022-11-08 15:48:32.040075100 +0530 +@@ -11,6 +11,7 @@ + * @author Joas Schilling + * @author Roeland Jago Douma + * @author Thomas Citharel ++ * @author Richard Steinmetz + * + * @license GNU AGPL version 3 or any later version + * +@@ -32,18 +33,23 @@ + + use DateTimeImmutable; + use OCA\DAV\CalDAV\CalDavBackend; ++use OCA\DAV\Connector\Sabre\Principal; + use OCP\AppFramework\Utility\ITimeFactory; ++use OCP\IConfig; + use OCP\IGroup; + use OCP\IGroupManager; + use OCP\IUser; + use OCP\IUserManager; ++use Psr\Log\LoggerInterface; + use Sabre\VObject; + use Sabre\VObject\Component\VAlarm; + use Sabre\VObject\Component\VEvent; + use Sabre\VObject\InvalidDataException; + use Sabre\VObject\ParseException; + use Sabre\VObject\Recur\EventIterator; ++use Sabre\VObject\Recur\MaxInstancesExceededException; + use Sabre\VObject\Recur\NoInstancesException; ++use function count; + use function strcasecmp; + + class ReminderService { +@@ -66,6 +72,15 @@ + /** @var ITimeFactory */ + private $timeFactory; + ++ /** @var IConfig */ ++ private $config; ++ ++ /** @var LoggerInterface */ ++ private $logger; ++ ++ /** @var Principal */ ++ private $principalConnector; ++ + public const REMINDER_TYPE_EMAIL = 'EMAIL'; + public const REMINDER_TYPE_DISPLAY = 'DISPLAY'; + public const REMINDER_TYPE_AUDIO = 'AUDIO'; +@@ -81,28 +96,24 @@ + self::REMINDER_TYPE_AUDIO + ]; + +- /** +- * ReminderService constructor. +- * +- * @param Backend $backend +- * @param NotificationProviderManager $notificationProviderManager +- * @param IUserManager $userManager +- * @param IGroupManager $groupManager +- * @param CalDavBackend $caldavBackend +- * @param ITimeFactory $timeFactory +- */ + public function __construct(Backend $backend, + NotificationProviderManager $notificationProviderManager, + IUserManager $userManager, + IGroupManager $groupManager, + CalDavBackend $caldavBackend, +- ITimeFactory $timeFactory) { ++ ITimeFactory $timeFactory, ++ IConfig $config, ++ LoggerInterface $logger, ++ Principal $principalConnector) { + $this->backend = $backend; + $this->notificationProviderManager = $notificationProviderManager; + $this->userManager = $userManager; + $this->groupManager = $groupManager; + $this->caldavBackend = $caldavBackend; + $this->timeFactory = $timeFactory; ++ $this->config = $config; ++ $this->logger = $logger; ++ $this->principalConnector = $principalConnector; + } + + /** +@@ -111,8 +122,11 @@ + * @throws NotificationProvider\ProviderNotAvailableException + * @throws NotificationTypeDoesNotExistException + */ +- public function processReminders():void { ++ public function processReminders() :void { + $reminders = $this->backend->getRemindersToProcess(); ++ $this->logger->debug('{numReminders} reminders to process', [ ++ 'numReminders' => count($reminders), ++ ]); + + foreach ($reminders as $reminder) { + $calendarData = is_resource($reminder['calendardata']) +@@ -125,34 +139,61 @@ + + $vcalendar = $this->parseCalendarData($calendarData); + if (!$vcalendar) { ++ $this->logger->debug('Reminder {id} does not belong to a valid calendar', [ ++ 'id' => $reminder['id'], ++ ]); + $this->backend->removeReminder($reminder['id']); + continue; + } + + $vevent = $this->getVEventByRecurrenceId($vcalendar, $reminder['recurrence_id'], $reminder['is_recurrence_exception']); + if (!$vevent) { ++ $this->logger->debug('Reminder {id} does not belong to a valid event', [ ++ 'id' => $reminder['id'], ++ ]); + $this->backend->removeReminder($reminder['id']); + continue; + } + + if ($this->wasEventCancelled($vevent)) { ++ $this->logger->debug('Reminder {id} belongs to a cancelled event', [ ++ 'id' => $reminder['id'], ++ ]); + $this->deleteOrProcessNext($reminder, $vevent); + continue; + } + + if (!$this->notificationProviderManager->hasProvider($reminder['type'])) { ++ $this->logger->debug('Reminder {id} does not belong to a valid notification provider', [ ++ 'id' => $reminder['id'], ++ ]); + $this->deleteOrProcessNext($reminder, $vevent); + continue; + } + +- $users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']); ++ if ($this->config->getAppValue('dav', 'sendEventRemindersToSharedGroupMembers', 'yes') === 'no') { ++ $users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']); ++ } else { ++ $users = []; ++ } ++ + $user = $this->getUserFromPrincipalURI($reminder['principaluri']); + if ($user) { + $users[] = $user; + } + ++ $userPrincipalEmailAddresses = []; ++ $userPrincipal = $this->principalConnector->getPrincipalByPath($reminder['principaluri']); ++ if ($userPrincipal) { ++ $userPrincipalEmailAddresses = $this->principalConnector->getEmailAddressesOfPrincipal($userPrincipal); ++ } ++ ++ $this->logger->debug('Reminder {id} will be sent to {numUsers} users', [ ++ 'id' => $reminder['id'], ++ 'numUsers' => count($users), ++ ]); + $notificationProvider = $this->notificationProviderManager->getProvider($reminder['type']); +- $notificationProvider->send($vevent, $reminder['displayname'], $users); ++ $notificationProvider->send($vevent, $reminder['displayname'], $userPrincipalEmailAddresses, $users); + + $this->deleteOrProcessNext($reminder, $vevent); + } +@@ -235,6 +276,10 @@ + // instance. We are skipping this event from the output + // entirely. + return; ++ } catch (MaxInstancesExceededException $e) { ++ // The event has more than 3500 recurring-instances ++ // so we can ignore it ++ return; + } + + while ($iterator->valid() && count($processedAlarms) < count($masterAlarms)) { +@@ -776,4 +821,4 @@ + private function isRecurring(VEvent $vevent):bool { + return isset($vevent->RRULE) || isset($vevent->RDATE); + } +-} ++} +\ No newline at end of file + +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php 2022-09-06 21:39:44.135827300 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider-new.php 2022-11-08 13:41:39.450075100 +0530 +@@ -189,4 +189,4 @@ + + return clone $vevent->DTSTART; + } +-} ++} +\ No newline at end of file + +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php 2022-09-06 21:39:44.135827300 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider-new.php 2022-11-08 13:43:04.470075100 +0530 +@@ -34,11 +34,12 @@ + use DateTime; + use OCP\IConfig; + use OCP\IL10N; +-use OCP\ILogger; + use OCP\IURLGenerator; + use OCP\L10N\IFactory as L10NFactory; + use OCP\Mail\IEMailTemplate; + use OCP\Mail\IMailer; ++use OCP\IUser; ++use Psr\Log\LoggerInterface; + use Sabre\VObject; + use Sabre\VObject\Component\VEvent; + use Sabre\VObject\Parameter; +@@ -54,19 +55,11 @@ + /** @var string */ + public const NOTIFICATION_TYPE = 'EMAIL'; + +- /** @var IMailer */ +- private $mailer; ++ private IMailer $mailer; + +- /** +- * @param IConfig $config +- * @param IMailer $mailer +- * @param ILogger $logger +- * @param L10NFactory $l10nFactory +- * @param IUrlGenerator $urlGenerator +- */ + public function __construct(IConfig $config, + IMailer $mailer, +- ILogger $logger, ++ LoggerInterface $logger, + L10NFactory $l10nFactory, + IURLGenerator $urlGenerator) { + parent::__construct($logger, $l10nFactory, $urlGenerator, $config); +@@ -78,16 +71,28 @@ + * + * @param VEvent $vevent + * @param string $calendarDisplayName ++ * @param string[] $principalEmailAddresses + * @param array $users + * @throws \Exception + */ + public function send(VEvent $vevent, + string $calendarDisplayName, ++ array $principalEmailAddresses, + array $users = []):void { + $fallbackLanguage = $this->getFallbackLanguage(); + ++ $organizerEmailAddress = null; ++ if (isset($vevent->ORGANIZER)) { ++ $organizerEmailAddress = $this->getEMailAddressOfAttendee($vevent->ORGANIZER); ++ } ++ + $emailAddressesOfSharees = $this->getEMailAddressesOfAllUsersWithWriteAccessToCalendar($users); +- $emailAddressesOfAttendees = $this->getAllEMailAddressesFromEvent($vevent); ++ $emailAddressesOfAttendees = []; ++ if (count($principalEmailAddresses) === 0 ++ || ($organizerEmailAddress && in_array($organizerEmailAddress, $principalEmailAddresses, true)) ++ ) { ++ $emailAddressesOfAttendees = $this->getAllEMailAddressesFromEvent($vevent); ++ } + + // Quote from php.net: + // If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. +@@ -133,7 +138,7 @@ + $this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]); + } + } catch (\Exception $ex) { +- $this->logger->logException($ex, ['app' => 'dav']); ++ $this->logger->error($ex->getMessage(), ['app' => 'dav', 'exception' => $ex]); + } + } + } +@@ -175,10 +180,6 @@ + } + } + +- /** +- * @param string $path +- * @return string +- */ + private function getAbsoluteImagePath(string $path):string { + return $this->urlGenerator->getAbsoluteURL( + $this->urlGenerator->imagePath('core', $path) +@@ -214,9 +215,8 @@ + } + + /** +- * @param array $emails +- * @param string $defaultLanguage +- * @return array ++ * @param array $emails ++ * @return array + */ + private function sortEMailAddressesByLanguage(array $emails, + string $defaultLanguage):array { +@@ -241,7 +241,7 @@ + + /** + * @param VEvent $vevent +- * @return array ++ * @return array + */ + private function getAllEMailAddressesFromEvent(VEvent $vevent):array { + $emailAddresses = []; +@@ -287,7 +287,7 @@ + $properties = []; + + $langProp = $attendee->offsetGet('LANG'); +- if ($langProp instanceof VObject\Parameter) { ++ if ($langProp instanceof VObject\Parameter && $langProp->getValue() !== null) { + $properties['LANG'] = $langProp->getValue(); + } + +@@ -297,18 +297,15 @@ + } + + if (isset($vevent->ORGANIZER) && $this->hasAttendeeMailURI($vevent->ORGANIZER)) { +- $emailAddresses[$this->getEMailAddressOfAttendee($vevent->ORGANIZER)] = []; ++ $organizerEmailAddress = $this->getEMailAddressOfAttendee($vevent->ORGANIZER); ++ if ($organizerEmailAddress !== null) { ++ $emailAddresses[$organizerEmailAddress] = []; ++ } + } + + return $emailAddresses; + } + +- +- +- /** +- * @param VObject\Property $attendee +- * @return string +- */ + private function getCUTypeOfAttendee(VObject\Property $attendee):string { + $cuType = $attendee->offsetGet('CUTYPE'); + if ($cuType instanceof VObject\Parameter) { +@@ -318,10 +315,6 @@ + return 'INDIVIDUAL'; + } + +- /** +- * @param VObject\Property $attendee +- * @return string +- */ + private function getPartstatOfAttendee(VObject\Property $attendee):string { + $partstat = $attendee->offsetGet('PARTSTAT'); + if ($partstat instanceof VObject\Parameter) { +@@ -331,19 +324,11 @@ + return 'NEEDS-ACTION'; + } + +- /** +- * @param VObject\Property $attendee +- * @return bool +- */ +- private function hasAttendeeMailURI(VObject\Property $attendee):bool { ++ private function hasAttendeeMailURI(VObject\Property $attendee): bool { + return stripos($attendee->getValue(), 'mailto:') === 0; + } + +- /** +- * @param VObject\Property $attendee +- * @return string|null +- */ +- private function getEMailAddressOfAttendee(VObject\Property $attendee):?string { ++ private function getEMailAddressOfAttendee(VObject\Property $attendee): ?string { + if (!$this->hasAttendeeMailURI($attendee)) { + return null; + } +@@ -356,8 +341,8 @@ + } + + /** +- * @param array $users +- * @return array ++ * @param IUser[] $users ++ * @return array + */ + private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array { + $emailAddresses = []; +@@ -380,12 +365,9 @@ + } + + /** +- * @param IL10N $l10n +- * @param VEvent $vevent +- * @return string + * @throws \Exception + */ +- private function generateDateString(IL10N $l10n, VEvent $vevent):string { ++ private function generateDateString(IL10N $l10n, VEvent $vevent): string { + $isAllDay = $vevent->DTSTART instanceof Property\ICalendar\Date; + + /** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtstart */ +@@ -451,57 +433,27 @@ + . ' (' . $startTimezone . ')'; + } + +- /** +- * @param DateTime $dtStart +- * @param DateTime $dtEnd +- * @return bool +- */ + private function isDayEqual(DateTime $dtStart, + DateTime $dtEnd):bool { + return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); + } + +- /** +- * @param IL10N $l10n +- * @param DateTime $dt +- * @return string +- */ + private function getWeekDayName(IL10N $l10n, DateTime $dt):string { +- return $l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); ++ return (string)$l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); + } + +- /** +- * @param IL10N $l10n +- * @param DateTime $dt +- * @return string +- */ + private function getDateString(IL10N $l10n, DateTime $dt):string { +- return $l10n->l('date', $dt, ['width' => 'medium']); ++ return (string)$l10n->l('date', $dt, ['width' => 'medium']); + } + +- /** +- * @param IL10N $l10n +- * @param DateTime $dt +- * @return string +- */ + private function getDateTimeString(IL10N $l10n, DateTime $dt):string { +- return $l10n->l('datetime', $dt, ['width' => 'medium|short']); ++ return (string)$l10n->l('datetime', $dt, ['width' => 'medium|short']); + } + +- /** +- * @param IL10N $l10n +- * @param DateTime $dt +- * @return string +- */ + private function getTimeString(IL10N $l10n, DateTime $dt):string { +- return $l10n->l('time', $dt, ['width' => 'short']); ++ return (string)$l10n->l('time', $dt, ['width' => 'short']); + } + +- /** +- * @param VEvent $vevent +- * @param IL10N $l10n +- * @return string +- */ + private function getTitleFromVEvent(VEvent $vevent, IL10N $l10n):string { + if (isset($vevent->SUMMARY)) { + return (string)$vevent->SUMMARY; +@@ -509,4 +461,4 @@ + + return $l10n->t('Untitled event'); + } +-} ++} +\ No newline at end of file + +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php 2022-09-06 21:39:44.135827300 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider-new.php 2022-11-08 15:47:09.910075100 +0530 +@@ -10,6 +10,7 @@ + * @author Georg Ehrke + * @author Roeland Jago Douma + * @author Thomas Citharel ++ * @author Richard Steinmetz + * + * @license GNU AGPL version 3 or any later version + * +@@ -32,12 +33,12 @@ + use OCA\DAV\AppInfo\Application; + use OCP\AppFramework\Utility\ITimeFactory; + use OCP\IConfig; +-use OCP\ILogger; + use OCP\IURLGenerator; + use OCP\IUser; + use OCP\L10N\IFactory as L10NFactory; + use OCP\Notification\IManager; + use OCP\Notification\INotification; ++use Psr\Log\LoggerInterface; + use Sabre\VObject\Component\VEvent; + use Sabre\VObject\Property; + +@@ -57,17 +58,9 @@ + /** @var ITimeFactory */ + private $timeFactory; + +- /** +- * @param IConfig $config +- * @param IManager $manager +- * @param ILogger $logger +- * @param L10NFactory $l10nFactory +- * @param IUrlGenerator $urlGenerator +- * @param ITimeFactory $timeFactory +- */ + public function __construct(IConfig $config, + IManager $manager, +- ILogger $logger, ++ LoggerInterface $logger, + L10NFactory $l10nFactory, + IURLGenerator $urlGenerator, + ITimeFactory $timeFactory) { +@@ -81,11 +74,13 @@ + * + * @param VEvent $vevent + * @param string $calendarDisplayName ++ * @param string[] $principalEmailAddresses + * @param IUser[] $users + * @throws \Exception + */ + public function send(VEvent $vevent, +- string $calendarDisplayName = null, ++ string $calendarDisplayName, ++ array $principalEmailAddresses, + array $users = []):void { + if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') { + return; +@@ -117,8 +112,6 @@ + } + + /** +- * @var VEvent $vevent +- * @return array + * @throws \Exception + */ + protected function extractEventDetails(VEvent $vevent):array { +@@ -145,4 +138,4 @@ + 'end_timezone' => $end->getDateTime()->getTimezone()->getName(), + ]; + } +-} ++} +\ No newline at end of file + +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php 2022-09-06 21:39:44.135827300 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider-new.php 2022-11-08 15:47:09.910075100 +0530 +@@ -10,6 +10,7 @@ + * @author Georg Ehrke + * @author Roeland Jago Douma + * @author Thomas Citharel ++ * @author Richard Steinmetz + * + * @license GNU AGPL version 3 or any later version + * +@@ -32,12 +33,12 @@ + use OCA\DAV\AppInfo\Application; + use OCP\AppFramework\Utility\ITimeFactory; + use OCP\IConfig; +-use OCP\ILogger; + use OCP\IURLGenerator; + use OCP\IUser; + use OCP\L10N\IFactory as L10NFactory; + use OCP\Notification\IManager; + use OCP\Notification\INotification; ++use Psr\Log\LoggerInterface; + use Sabre\VObject\Component\VEvent; + use Sabre\VObject\Property; + +@@ -57,17 +58,9 @@ + /** @var ITimeFactory */ + private $timeFactory; + +- /** +- * @param IConfig $config +- * @param IManager $manager +- * @param ILogger $logger +- * @param L10NFactory $l10nFactory +- * @param IUrlGenerator $urlGenerator +- * @param ITimeFactory $timeFactory +- */ + public function __construct(IConfig $config, + IManager $manager, +- ILogger $logger, ++ LoggerInterface $logger, + L10NFactory $l10nFactory, + IURLGenerator $urlGenerator, + ITimeFactory $timeFactory) { +@@ -81,11 +74,13 @@ + * + * @param VEvent $vevent + * @param string $calendarDisplayName ++ * @param string[] $principalEmailAddresses + * @param IUser[] $users + * @throws \Exception + */ + public function send(VEvent $vevent, +- string $calendarDisplayName = null, ++ string $calendarDisplayName, ++ array $principalEmailAddresses, + array $users = []):void { + if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') { + return; +@@ -117,8 +112,6 @@ + } + + /** +- * @var VEvent $vevent +- * @return array + * @throws \Exception + */ + protected function extractEventDetails(VEvent $vevent):array { +@@ -145,4 +138,4 @@ + 'end_timezone' => $end->getDateTime()->getTimezone()->getName(), + ]; + } +-} ++} +\ No newline at end of file -- GitLab From db889ff06e9aa8f15256bd23081ac5d26001bbc5 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Tue, 8 Nov 2022 17:24:27 +0530 Subject: [PATCH 02/11] new patch for multiple email notification fix --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 505f1197..561443f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ARG NEWS_VERSION="18.1.1" ARG QUOTA_WARN_VERSION="1.14.0" ARG NOTES_VERSION="4.5.1" ARG CONTACTS_JOB_ID="400045" -ARG CALENDAR_JOB_ID="414851" +ARG CALENDAR_JOB_ID="417988" ARG USER_BACKEND_RAW_SQL_VERSION="1.3.0" ARG EMAIL_RECOVERY_JOB_ID="389385" ARG RAINLOOP_VERSION="7.2.5" -- GitLab From 252738fa203df9487f39fda237c71a7d4ea1108d Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Tue, 8 Nov 2022 17:39:36 +0530 Subject: [PATCH 03/11] new patch for multiple email notification fix --- patches/022-multiplenotification.patch | 70 ++++---------------------- 1 file changed, 11 insertions(+), 59 deletions(-) diff --git a/patches/022-multiplenotification.patch b/patches/022-multiplenotification.patch index b38af98c..b1779c34 100644 --- a/patches/022-multiplenotification.patch +++ b/patches/022-multiplenotification.patch @@ -720,81 +720,33 @@ +} \ No newline at end of file ---- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider-new.php 2022-11-08 15:47:09.910075100 +0530 -@@ -10,6 +10,7 @@ +--- ./apps/dav/lib/CalDAV/Reminder/INotificationProvider.php 2022-09-06 21:39:44.135827300 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/INotificationProvider-new.php 2022-11-08 13:39:32.800075100 +0530 +@@ -8,6 +8,7 @@ + * @author Christoph Wurst * @author Georg Ehrke * @author Roeland Jago Douma - * @author Thomas Citharel + * @author Richard Steinmetz * * @license GNU AGPL version 3 or any later version * -@@ -32,12 +33,12 @@ - use OCA\DAV\AppInfo\Application; - use OCP\AppFramework\Utility\ITimeFactory; - use OCP\IConfig; --use OCP\ILogger; - use OCP\IURLGenerator; - use OCP\IUser; - use OCP\L10N\IFactory as L10NFactory; - use OCP\Notification\IManager; - use OCP\Notification\INotification; -+use Psr\Log\LoggerInterface; - use Sabre\VObject\Component\VEvent; - use Sabre\VObject\Property; - -@@ -57,17 +58,9 @@ - /** @var ITimeFactory */ - private $timeFactory; - -- /** -- * @param IConfig $config -- * @param IManager $manager -- * @param ILogger $logger -- * @param L10NFactory $l10nFactory -- * @param IUrlGenerator $urlGenerator -- * @param ITimeFactory $timeFactory -- */ - public function __construct(IConfig $config, - IManager $manager, -- ILogger $logger, -+ LoggerInterface $logger, - L10NFactory $l10nFactory, - IURLGenerator $urlGenerator, - ITimeFactory $timeFactory) { -@@ -81,11 +74,13 @@ +@@ -42,10 +43,12 @@ * * @param VEvent $vevent * @param string $calendarDisplayName -+ * @param string[] $principalEmailAddresses ++ * @param string[] $principalEmailAddresses All email addresses associated to the principal owning the calendar object * @param IUser[] $users - * @throws \Exception + * @return void */ public function send(VEvent $vevent, -- string $calendarDisplayName = null, -+ string $calendarDisplayName, -+ array $principalEmailAddresses, - array $users = []):void { - if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') { - return; -@@ -117,8 +112,6 @@ - } - - /** -- * @var VEvent $vevent -- * @return array - * @throws \Exception - */ - protected function extractEventDetails(VEvent $vevent):array { -@@ -145,4 +138,4 @@ - 'end_timezone' => $end->getDateTime()->getTimezone()->getName(), - ]; - } + string $calendarDisplayName, ++ array $principalEmailAddresses, + array $users = []): void; -} +} \ No newline at end of file + --- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php 2022-09-06 21:39:44.135827300 +0530 +++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider-new.php 2022-11-08 15:47:09.910075100 +0530 @@ -10,6 +10,7 @@ -- GitLab From 49d026c45a2a90b913b372839dd5c41e1d554769 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Tue, 8 Nov 2022 17:57:29 +0530 Subject: [PATCH 04/11] version bump --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 561443f1..9334eb2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,19/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,20/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images -- GitLab From 4b73f3910d330101283cebe77097642dd9599702 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 9 Nov 2022 11:36:04 +0530 Subject: [PATCH 05/11] version bump --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9334eb2f..633b21c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,20/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,21/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images -- GitLab From 8b95f0a2545cc35cd375e8c9f88bf56d10805e0f Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 9 Nov 2022 11:41:16 +0530 Subject: [PATCH 06/11] version bump --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 633b21c4..8b3ced9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,21/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,22/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -136,7 +136,7 @@ RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-o RUN patch -u ${BASE_DIR}/apps/settings/lib/Sections/Personal/Groupware.php -i ${TMP_PATCH_DIR}/019-groupware.patch RUN patch -u ${BASE_DIR}/lib/private/Notification/Manager.php -i ${TMP_PATCH_DIR}/020-fairuse-notification-fix.patch RUN patch -u ${BASE_DIR}/apps/files/js/files.js -i ${TMP_PATCH_DIR}/021-repeated-storage-dialog-fix.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch +#RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch RUN rm -rf ${TMP_PATCH_DIR} # show reset pwd page with a query param -- GitLab From d34d8a6066b25aece38ee219c3f0ba5a1085a57e Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 9 Nov 2022 11:54:06 +0530 Subject: [PATCH 07/11] version bump --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b3ced9e..2f2b328e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,22/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,23/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -136,7 +136,7 @@ RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-o RUN patch -u ${BASE_DIR}/apps/settings/lib/Sections/Personal/Groupware.php -i ${TMP_PATCH_DIR}/019-groupware.patch RUN patch -u ${BASE_DIR}/lib/private/Notification/Manager.php -i ${TMP_PATCH_DIR}/020-fairuse-notification-fix.patch RUN patch -u ${BASE_DIR}/apps/files/js/files.js -i ${TMP_PATCH_DIR}/021-repeated-storage-dialog-fix.patch -#RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch RUN rm -rf ${TMP_PATCH_DIR} # show reset pwd page with a query param -- GitLab From 30519aa6428b18426aab4d1045ddf5cffdf72a53 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 9 Nov 2022 12:27:06 +0530 Subject: [PATCH 08/11] fix patch --- Dockerfile | 2 +- patches/022-multiplenotification.patch | 64 +++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f2b328e..72a34d9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,23/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,24/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images diff --git a/patches/022-multiplenotification.patch b/patches/022-multiplenotification.patch index b1779c34..f487f94a 100644 --- a/patches/022-multiplenotification.patch +++ b/patches/022-multiplenotification.patch @@ -442,8 +442,67 @@ \ No newline at end of file --- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider-new.php 2022-11-08 13:41:39.450075100 +0530 -@@ -189,4 +189,4 @@ ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider-new.php 2022-11-09 12:25:04.761749300 +0530 +@@ -10,6 +10,7 @@ + * @author Georg Ehrke + * @author Joas Schilling + * @author Roeland Jago Douma ++ * @author Richard Steinmetz + * + * @license GNU AGPL version 3 or any later version + * +@@ -32,10 +33,10 @@ + use OCA\DAV\CalDAV\Reminder\INotificationProvider; + use OCP\IConfig; + use OCP\IL10N; +-use OCP\ILogger; + use OCP\IURLGenerator; + use OCP\IUser; + use OCP\L10N\IFactory as L10NFactory; ++use Psr\Log\LoggerInterface; + use Sabre\VObject\Component\VEvent; + use Sabre\VObject\DateTimeParser; + use Sabre\VObject\Property; +@@ -50,8 +51,7 @@ + /** @var string */ + public const NOTIFICATION_TYPE = ''; + +- /** @var ILogger */ +- protected $logger; ++ protected LoggerInterface $logger; + + /** @var L10NFactory */ + protected $l10nFactory; +@@ -68,13 +68,7 @@ + /** @var IConfig */ + protected $config; + +- /** +- * @param ILogger $logger +- * @param L10NFactory $l10nFactory +- * @param IConfig $config +- * @param IUrlGenerator $urlGenerator +- */ +- public function __construct(ILogger $logger, ++ public function __construct(LoggerInterface $logger, + L10NFactory $l10nFactory, + IURLGenerator $urlGenerator, + IConfig $config) { +@@ -89,11 +83,13 @@ + * + * @param VEvent $vevent + * @param string $calendarDisplayName ++ * @param string[] $principalEmailAddresses + * @param IUser[] $users + * @return void + */ + abstract public function send(VEvent $vevent, + string $calendarDisplayName, ++ array $principalEmailAddresses, + array $users = []): void; + + /** +@@ -189,4 +185,4 @@ return clone $vevent->DTSTART; } @@ -451,6 +510,7 @@ +} \ No newline at end of file + --- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php 2022-09-06 21:39:44.135827300 +0530 +++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider-new.php 2022-11-08 13:43:04.470075100 +0530 @@ -34,11 +34,12 @@ -- GitLab From 77801289d372017883058289d9610e7d0e834263 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 9 Nov 2022 13:12:03 +0530 Subject: [PATCH 09/11] removed patch --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 72a34d9e..4ca01e11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,24/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,25/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -136,7 +136,7 @@ RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-o RUN patch -u ${BASE_DIR}/apps/settings/lib/Sections/Personal/Groupware.php -i ${TMP_PATCH_DIR}/019-groupware.patch RUN patch -u ${BASE_DIR}/lib/private/Notification/Manager.php -i ${TMP_PATCH_DIR}/020-fairuse-notification-fix.patch RUN patch -u ${BASE_DIR}/apps/files/js/files.js -i ${TMP_PATCH_DIR}/021-repeated-storage-dialog-fix.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch +#RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch RUN rm -rf ${TMP_PATCH_DIR} # show reset pwd page with a query param -- GitLab From 7ad4f8ff54c2c770b129a14b6be072d80fb22436 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 10 Nov 2022 11:34:30 +0530 Subject: [PATCH 10/11] fix patch --- Dockerfile | 4 +- patches/022-multiplenotification.patch | 763 ++----------------------- 2 files changed, 53 insertions(+), 714 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ca01e11..5d830c15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG GOOGLE_INTEGRATION_VERSION="1.0.8" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" ARG OIDC_LOGIN_VERSION="2.3.3" -RUN sed -i 's/23,0,9,1/23,0,9,25/' ${BASE_DIR}/version.php +RUN sed -i 's/23,0,9,1/23,0,9,26/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -136,7 +136,7 @@ RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-o RUN patch -u ${BASE_DIR}/apps/settings/lib/Sections/Personal/Groupware.php -i ${TMP_PATCH_DIR}/019-groupware.patch RUN patch -u ${BASE_DIR}/lib/private/Notification/Manager.php -i ${TMP_PATCH_DIR}/020-fairuse-notification-fix.patch RUN patch -u ${BASE_DIR}/apps/files/js/files.js -i ${TMP_PATCH_DIR}/021-repeated-storage-dialog-fix.patch -#RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/022-multiplenotification.patch RUN rm -rf ${TMP_PATCH_DIR} # show reset pwd page with a query param diff --git a/patches/022-multiplenotification.patch b/patches/022-multiplenotification.patch index f487f94a..7699ed7d 100644 --- a/patches/022-multiplenotification.patch +++ b/patches/022-multiplenotification.patch @@ -1,74 +1,9 @@ ---- ./apps/dav/lib/Connector/Sabre/Principal.php 2022-09-06 21:39:44.155827300 +0530 -+++ ./apps/dav/lib/Connector/Sabre/Principal-new.php 2022-11-08 15:51:57.600075100 +0530 -@@ -41,6 +41,9 @@ - use OCA\Circles\Exceptions\CircleNotFoundException; - use OCA\DAV\CalDAV\Proxy\ProxyMapper; - use OCA\DAV\Traits\PrincipalProxyTrait; -+use OCP\Accounts\IAccountManager; -+use OCP\Accounts\IAccountProperty; -+use OCP\Accounts\PropertyDoesNotExistException; - use OCP\App\IAppManager; - use OCP\AppFramework\QueryException; - use OCP\Constants; -@@ -64,6 +67,9 @@ - /** @var IGroupManager */ - private $groupManager; - -+ /** @var IAccountManager */ -+ private $accountManager; -+ - /** @var IShareManager */ - private $shareManager; - -@@ -95,6 +101,7 @@ - - public function __construct(IUserManager $userManager, - IGroupManager $groupManager, -+ IAccountManager $accountManager, - IShareManager $shareManager, - IUserSession $userSession, - IAppManager $appManager, -@@ -105,6 +112,7 @@ - string $principalPrefix = 'principals/users/') { - $this->userManager = $userManager; - $this->groupManager = $groupManager; -+ $this->accountManager = $accountManager; - $this->shareManager = $shareManager; - $this->userSession = $userSession; - $this->appManager = $appManager; -@@ -506,6 +514,7 @@ - /** - * @param IUser $user - * @return array -+ * @throws PropertyDoesNotExistException - */ - protected function userToPrincipal($user) { - $userId = $user->getUID(); -@@ -517,11 +526,18 @@ - '{http://nextcloud.com/ns}language' => $this->languageFactory->getUserLanguage($user), - ]; - -+ $account = $this->accountManager->getAccount($user); -+ $alternativeEmails = array_map(fn (IAccountProperty $property) => 'mailto:' . $property->getValue(), $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties()); -+ - $email = $user->getSystemEMailAddress(); - if (!empty($email)) { - $principal['{http://sabredav.org/ns}email-address'] = $email; - } - -+ if (!empty($alternativeEmails)) { -+ $principal['{DAV:}alternate-URI-set'] = $alternativeEmails; -+ } -+ - return $principal; - } - -@@ -591,4 +607,44 @@ +--- ./apps/dav/lib/Connector/Sabre/Principal.php 2022-11-10 11:08:52.094653000 +0530 ++++ ./apps/dav/lib/Connector/Sabre/Principal-new.php 2022-11-10 10:42:55.194653000 +0530 +@@ -591,4 +591,43 @@ return []; } --} -+ + /** + * Get all email addresses associated to a principal. + * @@ -108,28 +43,11 @@ + + return array_values(array_unique($emailAddresses)); + } -+} -\ No newline at end of file - ---- ./apps/dav/lib/CalDAV/Schedule/Plugin.php 2022-09-06 21:39:44.145827300 +0530 -+++ ./apps/dav/lib/CalDAV/Schedule/Plugin-new.php 2022-11-08 15:49:50.620075100 +0530 -@@ -9,6 +9,7 @@ - * @author Joas Schilling - * @author Roeland Jago Douma - * @author Thomas Citharel -+ * @author Richard Steinmetz - * - * @license GNU AGPL version 3 or any later version - * -@@ -30,6 +31,7 @@ + } - use DateTimeZone; - use OCA\DAV\CalDAV\CalDavBackend; -+use OCA\DAV\CalDAV\Calendar; - use OCA\DAV\CalDAV\CalendarHome; - use OCP\IConfig; - use Sabre\CalDAV\ICalendar; -@@ -45,6 +47,7 @@ +--- ./apps/dav/lib/CalDAV/Schedule/Plugin.php 2022-11-10 11:07:59.044653000 +0530 ++++ ./apps/dav/lib/CalDAV/Schedule/Plugin-new.php 2022-11-10 10:44:56.934653000 +0530 +@@ -45,6 +45,7 @@ use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VEvent; use Sabre\VObject\DateTimeParser; @@ -137,31 +55,21 @@ use Sabre\VObject\FreeBusyGenerator; use Sabre\VObject\ITip; use Sabre\VObject\Parameter; -@@ -163,6 +166,14 @@ +@@ -163,6 +164,13 @@ * @inheritDoc */ public function scheduleLocalDelivery(ITip\Message $iTipMessage):void { -+ /** @var Component|null $vevent */ -+ $vevent = $iTipMessage->message->VEVENT ?? null; -+ -+ // Strip VALARMs from incoming VEVENT -+ if ($vevent && isset($vevent->VALARM)) { -+ $vevent->remove('VALARM'); -+ } ++ /** @var Component|null $vevent */ ++ $vevent = $iTipMessage->message->VEVENT ?? null; + ++ // Strip VALARMs from incoming VEVENT ++ if ($vevent && isset($vevent->VALARM)) { ++ $vevent->remove('VALARM'); ++ } parent::scheduleLocalDelivery($iTipMessage); // We only care when the message was successfully delivered locally -@@ -178,7 +189,7 @@ - - // If parent::scheduleLocalDelivery set scheduleStatus to 1.2, - // it means that it was successfully delivered locally. -- // Meaning that the ACL plugin is loaded and that a principial -+ // Meaning that the ACL plugin is loaded and that a principal - // exists for the given recipient id, no need to double check - /** @var \Sabre\DAVACL\Plugin $aclPlugin */ - $aclPlugin = $this->server->getPlugin('acl'); -@@ -199,18 +210,10 @@ +@@ -199,17 +207,11 @@ return; } @@ -174,102 +82,16 @@ - if (!isset($vcalendar->VEVENT)) { - return; - } -- + - /** @var Component $vevent */ - $vevent = $vcalendar->VEVENT; -- + // We don't support autoresponses for recurrencing events for now if (isset($vevent->RRULE) || isset($vevent->RDATE)) { - return; -@@ -299,12 +302,14 @@ - return null; - } - -+ $isResourceOrRoom = strpos($principalUrl, 'principals/calendar-resources') === 0 || -+ strpos($principalUrl, 'principals/calendar-rooms') === 0; -+ - if (strpos($principalUrl, 'principals/users') === 0) { - [, $userId] = split($principalUrl); - $uri = $this->config->getUserValue($userId, 'dav', 'defaultCalendar', CalDavBackend::PERSONAL_CALENDAR_URI); - $displayName = CalDavBackend::PERSONAL_CALENDAR_NAME; -- } elseif (strpos($principalUrl, 'principals/calendar-resources') === 0 || -- strpos($principalUrl, 'principals/calendar-rooms') === 0) { -+ } elseif ($isResourceOrRoom) { - $uri = CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI; - $displayName = CalDavBackend::RESOURCE_BOOKING_CALENDAR_NAME; - } else { -@@ -316,9 +321,40 @@ - /** @var CalendarHome $calendarHome */ - $calendarHome = $this->server->tree->getNodeForPath($calendarHomePath); - if (!$calendarHome->childExists($uri)) { -- $calendarHome->getCalDAVBackend()->createCalendar($principalUrl, $uri, [ -- '{DAV:}displayname' => $displayName, -- ]); -+ // If the default calendar doesn't exist -+ if ($isResourceOrRoom) { -+ $calendarHome->getCalDAVBackend()->createCalendar($principalUrl, $uri, [ -+ '{DAV:}displayname' => $displayName, -+ ]); -+ } else { -+ // And we're not handling scheduling on resource/room booking -+ $userCalendars = []; -+ /** -+ * If the default calendar of the user isn't set and the -+ * fallback doesn't match any of the user's calendar -+ * try to find the first "personal" calendar we can write to -+ * instead of creating a new one. -+ * A appropriate personal calendar to receive invites: -+ * - isn't a calendar subscription -+ * - user can write to it (no virtual/3rd-party calendars) -+ * - calendar isn't a share -+ */ -+ foreach ($calendarHome->getChildren() as $node) { -+ if ($node instanceof Calendar && !$node->isSubscription() && $node->canWrite() && !$node->isShared() && !$node->isDeleted()) { -+ $userCalendars[] = $node; -+ } -+ } -+ -+ if (count($userCalendars) > 0) { -+ // Calendar backend returns calendar by calendarorder property -+ $uri = $userCalendars[0]->getName(); -+ } else { -+ // Otherwise if we have really nothing, create a new calendar -+ $calendarHome->getCalDAVBackend()->createCalendar($principalUrl, $uri, [ -+ '{DAV:}displayname' => $displayName, -+ ]); -+ } -+ } - } - - $result = $this->server->getPropertiesForPath($calendarHomePath . '/' . $uri, [], 1); -@@ -533,7 +569,7 @@ - } - - // If more than one Free-Busy property was returned, it means that an event -- // starts or ends inside this time-range, so it's not availabe and we return false -+ // starts or ends inside this time-range, so it's not available and we return false - if (count($freeBusyProperties) > 1) { - return false; - } -@@ -564,4 +600,4 @@ - - return $email; - } --} -+} -\ No newline at end of file ---- ./apps/dav/lib/CalDAV/Reminder/ReminderService.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/ReminderService-new.php 2022-11-08 15:48:32.040075100 +0530 -@@ -11,6 +11,7 @@ - * @author Joas Schilling - * @author Roeland Jago Douma - * @author Thomas Citharel -+ * @author Richard Steinmetz - * - * @license GNU AGPL version 3 or any later version - * -@@ -32,18 +33,23 @@ +--- ./apps/dav/lib/CalDAV/Reminder/ReminderService.php 2022-11-10 11:05:13.604653000 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/ReminderService-new.php 2022-11-10 10:53:04.134653000 +0530 +@@ -32,11 +32,14 @@ use DateTimeImmutable; use OCA\DAV\CalDAV\CalDavBackend; @@ -284,47 +106,31 @@ use Sabre\VObject; use Sabre\VObject\Component\VAlarm; use Sabre\VObject\Component\VEvent; - use Sabre\VObject\InvalidDataException; +@@ -44,6 +47,7 @@ use Sabre\VObject\ParseException; use Sabre\VObject\Recur\EventIterator; -+use Sabre\VObject\Recur\MaxInstancesExceededException; use Sabre\VObject\Recur\NoInstancesException; +use function count; use function strcasecmp; class ReminderService { -@@ -66,6 +72,15 @@ +@@ -66,6 +70,15 @@ /** @var ITimeFactory */ private $timeFactory; -+ /** @var IConfig */ -+ private $config; ++ /** @var IConfig */ ++ private $config; ++ /** @var LoggerInterface */ ++ private $logger; + -+ /** @var LoggerInterface */ -+ private $logger; ++ /** @var Principal */ ++ private $principalConnector; + -+ /** @var Principal */ -+ private $principalConnector; + public const REMINDER_TYPE_EMAIL = 'EMAIL'; public const REMINDER_TYPE_DISPLAY = 'DISPLAY'; public const REMINDER_TYPE_AUDIO = 'AUDIO'; -@@ -81,28 +96,24 @@ - self::REMINDER_TYPE_AUDIO - ]; - -- /** -- * ReminderService constructor. -- * -- * @param Backend $backend -- * @param NotificationProviderManager $notificationProviderManager -- * @param IUserManager $userManager -- * @param IGroupManager $groupManager -- * @param CalDavBackend $caldavBackend -- * @param ITimeFactory $timeFactory -- */ - public function __construct(Backend $backend, - NotificationProviderManager $notificationProviderManager, +@@ -96,15 +109,20 @@ IUserManager $userManager, IGroupManager $groupManager, CalDavBackend $caldavBackend, @@ -343,158 +149,14 @@ + $this->logger = $logger; + $this->principalConnector = $principalConnector; } - +- /** -@@ -111,8 +122,11 @@ - * @throws NotificationProvider\ProviderNotAvailableException - * @throws NotificationTypeDoesNotExistException - */ -- public function processReminders():void { -+ public function processReminders() :void { - $reminders = $this->backend->getRemindersToProcess(); -+ $this->logger->debug('{numReminders} reminders to process', [ -+ 'numReminders' => count($reminders), -+ ]); - - foreach ($reminders as $reminder) { - $calendarData = is_resource($reminder['calendardata']) -@@ -125,34 +139,61 @@ - - $vcalendar = $this->parseCalendarData($calendarData); - if (!$vcalendar) { -+ $this->logger->debug('Reminder {id} does not belong to a valid calendar', [ -+ 'id' => $reminder['id'], -+ ]); - $this->backend->removeReminder($reminder['id']); - continue; - } - - $vevent = $this->getVEventByRecurrenceId($vcalendar, $reminder['recurrence_id'], $reminder['is_recurrence_exception']); - if (!$vevent) { -+ $this->logger->debug('Reminder {id} does not belong to a valid event', [ -+ 'id' => $reminder['id'], -+ ]); - $this->backend->removeReminder($reminder['id']); - continue; - } - - if ($this->wasEventCancelled($vevent)) { -+ $this->logger->debug('Reminder {id} belongs to a cancelled event', [ -+ 'id' => $reminder['id'], -+ ]); - $this->deleteOrProcessNext($reminder, $vevent); - continue; - } - - if (!$this->notificationProviderManager->hasProvider($reminder['type'])) { -+ $this->logger->debug('Reminder {id} does not belong to a valid notification provider', [ -+ 'id' => $reminder['id'], -+ ]); - $this->deleteOrProcessNext($reminder, $vevent); - continue; - } - -- $users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']); -+ if ($this->config->getAppValue('dav', 'sendEventRemindersToSharedGroupMembers', 'yes') === 'no') { -+ $users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']); -+ } else { -+ $users = []; -+ } -+ - $user = $this->getUserFromPrincipalURI($reminder['principaluri']); - if ($user) { - $users[] = $user; - } - -+ $userPrincipalEmailAddresses = []; -+ $userPrincipal = $this->principalConnector->getPrincipalByPath($reminder['principaluri']); -+ if ($userPrincipal) { -+ $userPrincipalEmailAddresses = $this->principalConnector->getEmailAddressesOfPrincipal($userPrincipal); -+ } -+ -+ $this->logger->debug('Reminder {id} will be sent to {numUsers} users', [ -+ 'id' => $reminder['id'], -+ 'numUsers' => count($users), -+ ]); - $notificationProvider = $this->notificationProviderManager->getProvider($reminder['type']); -- $notificationProvider->send($vevent, $reminder['displayname'], $users); -+ $notificationProvider->send($vevent, $reminder['displayname'], $userPrincipalEmailAddresses, $users); - - $this->deleteOrProcessNext($reminder, $vevent); - } -@@ -235,6 +276,10 @@ - // instance. We are skipping this event from the output - // entirely. - return; -+ } catch (MaxInstancesExceededException $e) { -+ // The event has more than 3500 recurring-instances -+ // so we can ignore it -+ return; - } - - while ($iterator->valid() && count($processedAlarms) < count($masterAlarms)) { -@@ -776,4 +821,4 @@ - private function isRecurring(VEvent $vevent):bool { - return isset($vevent->RRULE) || isset($vevent->RDATE); - } --} -+} -\ No newline at end of file - ---- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider-new.php 2022-11-09 12:25:04.761749300 +0530 -@@ -10,6 +10,7 @@ - * @author Georg Ehrke - * @author Joas Schilling - * @author Roeland Jago Douma -+ * @author Richard Steinmetz - * - * @license GNU AGPL version 3 or any later version - * -@@ -32,10 +33,10 @@ - use OCA\DAV\CalDAV\Reminder\INotificationProvider; - use OCP\IConfig; - use OCP\IL10N; --use OCP\ILogger; - use OCP\IURLGenerator; - use OCP\IUser; - use OCP\L10N\IFactory as L10NFactory; -+use Psr\Log\LoggerInterface; - use Sabre\VObject\Component\VEvent; - use Sabre\VObject\DateTimeParser; - use Sabre\VObject\Property; -@@ -50,8 +51,7 @@ - /** @var string */ - public const NOTIFICATION_TYPE = ''; - -- /** @var ILogger */ -- protected $logger; -+ protected LoggerInterface $logger; - - /** @var L10NFactory */ - protected $l10nFactory; -@@ -68,13 +68,7 @@ - /** @var IConfig */ - protected $config; - -- /** -- * @param ILogger $logger -- * @param L10NFactory $l10nFactory -- * @param IConfig $config -- * @param IUrlGenerator $urlGenerator -- */ -- public function __construct(ILogger $logger, -+ public function __construct(LoggerInterface $logger, - L10NFactory $l10nFactory, - IURLGenerator $urlGenerator, - IConfig $config) { -@@ -89,11 +83,13 @@ + * Process reminders to activate * - * @param VEvent $vevent - * @param string $calendarDisplayName -+ * @param string[] $principalEmailAddresses - * @param IUser[] $users - * @return void + +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php 2022-11-10 11:18:14.574653000 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider-new.php 2022-11-10 10:49:41.084653000 +0530 +@@ -94,6 +94,7 @@ */ abstract public function send(VEvent $vevent, string $calendarDisplayName, @@ -502,60 +164,10 @@ array $users = []): void; /** -@@ -189,4 +185,4 @@ - return clone $vevent->DTSTART; - } --} -+} -\ No newline at end of file - - ---- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider-new.php 2022-11-08 13:43:04.470075100 +0530 -@@ -34,11 +34,12 @@ - use DateTime; - use OCP\IConfig; - use OCP\IL10N; --use OCP\ILogger; - use OCP\IURLGenerator; - use OCP\L10N\IFactory as L10NFactory; - use OCP\Mail\IEMailTemplate; - use OCP\Mail\IMailer; -+use OCP\IUser; -+use Psr\Log\LoggerInterface; - use Sabre\VObject; - use Sabre\VObject\Component\VEvent; - use Sabre\VObject\Parameter; -@@ -54,19 +55,11 @@ - /** @var string */ - public const NOTIFICATION_TYPE = 'EMAIL'; - -- /** @var IMailer */ -- private $mailer; -+ private IMailer $mailer; - -- /** -- * @param IConfig $config -- * @param IMailer $mailer -- * @param ILogger $logger -- * @param L10NFactory $l10nFactory -- * @param IUrlGenerator $urlGenerator -- */ - public function __construct(IConfig $config, - IMailer $mailer, -- ILogger $logger, -+ LoggerInterface $logger, - L10NFactory $l10nFactory, - IURLGenerator $urlGenerator) { - parent::__construct($logger, $l10nFactory, $urlGenerator, $config); -@@ -78,16 +71,28 @@ - * - * @param VEvent $vevent - * @param string $calendarDisplayName -+ * @param string[] $principalEmailAddresses - * @param array $users - * @throws \Exception +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php 2022-11-10 11:18:14.534653000 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider-new.php 2022-11-10 10:51:15.364653000 +0530 +@@ -83,11 +83,23 @@ */ public function send(VEvent $vevent, string $calendarDisplayName, @@ -569,7 +181,7 @@ + } + $emailAddressesOfSharees = $this->getEMailAddressesOfAllUsersWithWriteAccessToCalendar($users); -- $emailAddressesOfAttendees = $this->getAllEMailAddressesFromEvent($vevent); + $emailAddressesOfAttendees = $this->getAllEMailAddressesFromEvent($vevent); + $emailAddressesOfAttendees = []; + if (count($principalEmailAddresses) === 0 + || ($organizerEmailAddress && in_array($organizerEmailAddress, $principalEmailAddresses, true)) @@ -579,283 +191,20 @@ // Quote from php.net: // If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. -@@ -133,7 +138,7 @@ - $this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]); - } - } catch (\Exception $ex) { -- $this->logger->logException($ex, ['app' => 'dav']); -+ $this->logger->error($ex->getMessage(), ['app' => 'dav', 'exception' => $ex]); - } - } - } -@@ -175,10 +180,6 @@ - } - } - -- /** -- * @param string $path -- * @return string -- */ - private function getAbsoluteImagePath(string $path):string { - return $this->urlGenerator->getAbsoluteURL( - $this->urlGenerator->imagePath('core', $path) -@@ -214,9 +215,8 @@ - } - - /** -- * @param array $emails -- * @param string $defaultLanguage -- * @return array -+ * @param array $emails -+ * @return array - */ - private function sortEMailAddressesByLanguage(array $emails, - string $defaultLanguage):array { -@@ -241,7 +241,7 @@ - - /** - * @param VEvent $vevent -- * @return array -+ * @return array - */ - private function getAllEMailAddressesFromEvent(VEvent $vevent):array { - $emailAddresses = []; -@@ -287,7 +287,7 @@ - $properties = []; - - $langProp = $attendee->offsetGet('LANG'); -- if ($langProp instanceof VObject\Parameter) { -+ if ($langProp instanceof VObject\Parameter && $langProp->getValue() !== null) { - $properties['LANG'] = $langProp->getValue(); - } - -@@ -297,18 +297,15 @@ - } - - if (isset($vevent->ORGANIZER) && $this->hasAttendeeMailURI($vevent->ORGANIZER)) { -- $emailAddresses[$this->getEMailAddressOfAttendee($vevent->ORGANIZER)] = []; -+ $organizerEmailAddress = $this->getEMailAddressOfAttendee($vevent->ORGANIZER); -+ if ($organizerEmailAddress !== null) { -+ $emailAddresses[$organizerEmailAddress] = []; -+ } - } - - return $emailAddresses; - } - -- -- -- /** -- * @param VObject\Property $attendee -- * @return string -- */ - private function getCUTypeOfAttendee(VObject\Property $attendee):string { - $cuType = $attendee->offsetGet('CUTYPE'); - if ($cuType instanceof VObject\Parameter) { -@@ -318,10 +315,6 @@ - return 'INDIVIDUAL'; - } -- /** -- * @param VObject\Property $attendee -- * @return string -- */ - private function getPartstatOfAttendee(VObject\Property $attendee):string { - $partstat = $attendee->offsetGet('PARTSTAT'); - if ($partstat instanceof VObject\Parameter) { -@@ -331,19 +324,11 @@ - return 'NEEDS-ACTION'; - } - -- /** -- * @param VObject\Property $attendee -- * @return bool -- */ -- private function hasAttendeeMailURI(VObject\Property $attendee):bool { -+ private function hasAttendeeMailURI(VObject\Property $attendee): bool { - return stripos($attendee->getValue(), 'mailto:') === 0; - } - -- /** -- * @param VObject\Property $attendee -- * @return string|null -- */ -- private function getEMailAddressOfAttendee(VObject\Property $attendee):?string { -+ private function getEMailAddressOfAttendee(VObject\Property $attendee): ?string { - if (!$this->hasAttendeeMailURI($attendee)) { - return null; - } -@@ -356,8 +341,8 @@ - } - - /** -- * @param array $users -- * @return array -+ * @param IUser[] $users -+ * @return array - */ - private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array { - $emailAddresses = []; -@@ -380,12 +365,9 @@ - } - - /** -- * @param IL10N $l10n -- * @param VEvent $vevent -- * @return string - * @throws \Exception - */ -- private function generateDateString(IL10N $l10n, VEvent $vevent):string { -+ private function generateDateString(IL10N $l10n, VEvent $vevent): string { - $isAllDay = $vevent->DTSTART instanceof Property\ICalendar\Date; - - /** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtstart */ -@@ -451,57 +433,27 @@ - . ' (' . $startTimezone . ')'; - } - -- /** -- * @param DateTime $dtStart -- * @param DateTime $dtEnd -- * @return bool -- */ - private function isDayEqual(DateTime $dtStart, - DateTime $dtEnd):bool { - return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); - } - -- /** -- * @param IL10N $l10n -- * @param DateTime $dt -- * @return string -- */ - private function getWeekDayName(IL10N $l10n, DateTime $dt):string { -- return $l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); -+ return (string)$l10n->l('weekdayName', $dt, ['width' => 'abbreviated']); - } - -- /** -- * @param IL10N $l10n -- * @param DateTime $dt -- * @return string -- */ - private function getDateString(IL10N $l10n, DateTime $dt):string { -- return $l10n->l('date', $dt, ['width' => 'medium']); -+ return (string)$l10n->l('date', $dt, ['width' => 'medium']); - } - -- /** -- * @param IL10N $l10n -- * @param DateTime $dt -- * @return string -- */ - private function getDateTimeString(IL10N $l10n, DateTime $dt):string { -- return $l10n->l('datetime', $dt, ['width' => 'medium|short']); -+ return (string)$l10n->l('datetime', $dt, ['width' => 'medium|short']); - } - -- /** -- * @param IL10N $l10n -- * @param DateTime $dt -- * @return string -- */ - private function getTimeString(IL10N $l10n, DateTime $dt):string { -- return $l10n->l('time', $dt, ['width' => 'short']); -+ return (string)$l10n->l('time', $dt, ['width' => 'short']); - } - -- /** -- * @param VEvent $vevent -- * @param IL10N $l10n -- * @return string -- */ - private function getTitleFromVEvent(VEvent $vevent, IL10N $l10n):string { - if (isset($vevent->SUMMARY)) { - return (string)$vevent->SUMMARY; -@@ -509,4 +461,4 @@ - - return $l10n->t('Untitled event'); - } --} -+} -\ No newline at end of file - ---- ./apps/dav/lib/CalDAV/Reminder/INotificationProvider.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/INotificationProvider-new.php 2022-11-08 13:39:32.800075100 +0530 -@@ -8,6 +8,7 @@ - * @author Christoph Wurst - * @author Georg Ehrke - * @author Roeland Jago Douma -+ * @author Richard Steinmetz - * - * @license GNU AGPL version 3 or any later version - * -@@ -42,10 +43,12 @@ - * - * @param VEvent $vevent - * @param string $calendarDisplayName -+ * @param string[] $principalEmailAddresses All email addresses associated to the principal owning the calendar object - * @param IUser[] $users - * @return void +--- ./apps/dav/lib/CalDAV/Reminder/INotificationProvider.php 2022-11-10 11:06:58.304653000 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/INotificationProvider-new.php 2022-11-10 10:40:31.934653000 +0530 +@@ -47,5 +47,6 @@ */ public function send(VEvent $vevent, string $calendarDisplayName, + array $principalEmailAddresses, array $users = []): void; --} -+} -\ No newline at end of file + } - ---- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php 2022-09-06 21:39:44.135827300 +0530 -+++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider-new.php 2022-11-08 15:47:09.910075100 +0530 -@@ -10,6 +10,7 @@ - * @author Georg Ehrke - * @author Roeland Jago Douma - * @author Thomas Citharel -+ * @author Richard Steinmetz - * - * @license GNU AGPL version 3 or any later version - * -@@ -32,12 +33,12 @@ - use OCA\DAV\AppInfo\Application; - use OCP\AppFramework\Utility\ITimeFactory; - use OCP\IConfig; --use OCP\ILogger; - use OCP\IURLGenerator; - use OCP\IUser; - use OCP\L10N\IFactory as L10NFactory; - use OCP\Notification\IManager; - use OCP\Notification\INotification; -+use Psr\Log\LoggerInterface; - use Sabre\VObject\Component\VEvent; - use Sabre\VObject\Property; - -@@ -57,17 +58,9 @@ - /** @var ITimeFactory */ - private $timeFactory; - -- /** -- * @param IConfig $config -- * @param IManager $manager -- * @param ILogger $logger -- * @param L10NFactory $l10nFactory -- * @param IUrlGenerator $urlGenerator -- * @param ITimeFactory $timeFactory -- */ - public function __construct(IConfig $config, - IManager $manager, -- ILogger $logger, -+ LoggerInterface $logger, - L10NFactory $l10nFactory, - IURLGenerator $urlGenerator, - ITimeFactory $timeFactory) { -@@ -81,11 +74,13 @@ - * - * @param VEvent $vevent - * @param string $calendarDisplayName -+ * @param string[] $principalEmailAddresses - * @param IUser[] $users +--- ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php 2022-11-10 11:18:14.614653000 +0530 ++++ ./apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider-new.php 2022-11-10 10:52:38.064653000 +0530 +@@ -85,12 +85,14 @@ * @throws \Exception */ public function send(VEvent $vevent, @@ -865,19 +214,9 @@ array $users = []):void { if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') { return; -@@ -117,8 +112,6 @@ - } + } - /** -- * @var VEvent $vevent -- * @return array - * @throws \Exception - */ - protected function extractEventDetails(VEvent $vevent):array { -@@ -145,4 +138,4 @@ - 'end_timezone' => $end->getDateTime()->getTimezone()->getName(), - ]; - } --} -+} -\ No newline at end of file ++ + $eventDetails = $this->extractEventDetails($vevent); + $eventDetails['calendar_displayname'] = $calendarDisplayName; + $eventUUID = (string) $vevent->UID; -- GitLab From a862356ce4aac4bdb3f7add652c16a09b59a9f7b Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 10 Nov 2022 12:13:14 +0530 Subject: [PATCH 11/11] added patch details --- patches/022-multiplenotification.patch | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/patches/022-multiplenotification.patch b/patches/022-multiplenotification.patch index 7699ed7d..8a7c8635 100644 --- a/patches/022-multiplenotification.patch +++ b/patches/022-multiplenotification.patch @@ -1,3 +1,9 @@ +From: Avinash +Date: Thu, 10 Nov 2022 12:09:27 +0100 +Subject: [PATCH] this patch solves the multiple notificaton issue in mail + +This patch fix the issue https://github.com/nextcloud/server/issues/21370 and taken the reference from https://github.com/nextcloud/server/issues/21370 + --- ./apps/dav/lib/Connector/Sabre/Principal.php 2022-11-10 11:08:52.094653000 +0530 +++ ./apps/dav/lib/Connector/Sabre/Principal-new.php 2022-11-10 10:42:55.194653000 +0530 @@ -591,4 +591,43 @@ -- GitLab