From ef2c3b8968e56cbd6d08aa22ae84b0289b9794bc Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Mon, 6 May 2024 13:40:26 +0530 Subject: [PATCH 1/6] patch for email template --- patches/015-email-mail-template.patch | 77 +++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 94663d39..747758a9 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -49,7 +49,39 @@ --- ./apps/dav/lib/CalDAV/Schedule/IMipService.php 2024-03-18 11:40:39 +++ ./apps/dav/lib/CalDAV/Schedule/IMipService-new.php 2024-03-18 13:47:17 -@@ -444,6 +444,51 @@ +@@ -169,10 +169,30 @@ + $oldUrl = self::readPropertyWithDefault($oldVEvent, 'URL', $defaultVal); + $data['meeting_url_html'] = !empty($oldUrl) && $oldUrl !== $data['meeting_url'] ? sprintf('%1$s', $oldUrl) : $data['meeting_url']; + +- $data['meeting_when_html'] = ++ if(isset($vEvent->RRULE)){ ++ $RRule= (string) $vEvent->RRULE->getValue(); ++ if (strpos($RRule, 'FREQ=DAILY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats daily:'); ++ } ++ if (strpos($RRule, 'FREQ=WEEKLY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats weekly:'); ++ } ++ if (strpos($RRule, 'FREQ=MONTHLY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats monthly:'); ++ } ++ if (strpos($RRule, 'FREQ=YEARLY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats yearly:'); ++ } ++ $data['meeting_when_html'] = + ($oldMeetingWhen !== $data['meeting_when'] && $oldMeetingWhen !== null) ++ ? sprintf("%s
%s%s", $oldMeetingWhen,$timeTitle, $data['meeting_when']) ++ : $data['meeting_when']; ++ } else { ++ $data['meeting_when_html'] = ++ ($oldMeetingWhen !== $data['meeting_when'] && $oldMeetingWhen !== null) + ? sprintf("%s
%s", $oldMeetingWhen, $data['meeting_when']) + : $data['meeting_when']; ++ } + } + return $data; + } +@@ -444,6 +464,51 @@ } /** @@ -101,8 +133,31 @@ * @param string $path * @return string */ -@@ -541,8 +586,14 @@ +@@ -537,12 +602,36 @@ + $data['meeting_title_html'] ?? $data['meeting_title'], $this->l10n->t('Title:'), + $this->getAbsoluteImagePath('caldav/title.png'), $data['meeting_title'], '', IMipPlugin::IMIP_INDENT); + if ($data['meeting_when'] !== '') { +- $template->addBodyListItem($data['meeting_when_html'] ?? $data['meeting_when'], $this->l10n->t('Time:'), ++ if(isset($vevent->RRULE)){ ++ $RRule=(string) $vevent->RRULE->getValue(); ++ if (strpos($RRule, 'FREQ=DAILY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats daily:'); ++ } ++ if (strpos($RRule, 'FREQ=WEEKLY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats weekly:'); ++ } ++ if (strpos($RRule, 'FREQ=MONTHLY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats monthly:'); ++ } ++ if (strpos($RRule, 'FREQ=YEARLY') !== false) { ++ $timeTitle = $this->l10n->t('Repeats yearly:'); ++ } ++ $template->addBodyListItem($data['meeting_when_html'] ?? $data['meeting_when'], $timeTitle, $this->getAbsoluteImagePath('caldav/time.png'), $data['meeting_when'], '', IMipPlugin::IMIP_INDENT); ++ } else { ++ $template->addBodyListItem($data['meeting_when_html'] ?? $data['meeting_when'], $this->l10n->t('Time:'), ++ $this->getAbsoluteImagePath('caldav/time.png'), $data['meeting_when'], '', IMipPlugin::IMIP_INDENT); ++ } } if ($data['meeting_location'] !== '') { - $template->addBodyListItem($data['meeting_location_html'] ?? $data['meeting_location'], $this->l10n->t('Location:'), @@ -118,7 +173,7 @@ } if ($data['meeting_url'] !== '') { $template->addBodyListItem($data['meeting_url_html'] ?? $data['meeting_url'], $this->l10n->t('Link:'), -@@ -637,7 +688,7 @@ +@@ -637,7 +726,7 @@ * @param $token */ public function addResponseButtons(IEMailTemplate $template, $token) { @@ -127,7 +182,7 @@ $this->l10n->t('Accept'), $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [ 'token' => $token, -@@ -645,20 +696,10 @@ +@@ -645,20 +734,10 @@ $this->l10n->t('Decline'), $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [ 'token' => $token, @@ -151,3 +206,17 @@ } public function getReplyingAttendee(Message $iTipMessage): ?Property { + +--- ./apps/dav/lib/CalDAV/EventComparisonService.php 2024-05-06 12:46:29 ++++ ./apps/dav/lib/CalDAV/EventComparisonService-new.php 2024-05-06 12:47:11 +@@ -113,7 +113,9 @@ + continue; + } + if($this->removeIfUnchanged($event, $newEventComponents)) { +- unset($oldEventComponents[$k]); ++ if($k!=1){ ++ unset($oldEventComponents[$k]); ++ } + } + } + } -- GitLab From 562339ce1a74a4507f7449803ceb7e5b69d97e47 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 9 May 2024 15:48:02 +0530 Subject: [PATCH 2/6] added recurring date on individual event change --- patches/015-email-mail-template.patch | 64 ++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 747758a9..6cb82b72 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -1,6 +1,38 @@ --- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2024-03-18 11:18:20 +++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2024-03-11 11:18:22 -@@ -242,6 +242,13 @@ +@@ -175,6 +175,31 @@ + $oldVevent = !empty($modified['old']) && is_array($modified['old']) ? array_pop($modified['old']) : null; + $isModified = isset($oldVevent); + ++ if (isset($vEvent->{'RECURRENCE-ID'}) && $modified['sentOld'] === 1) { ++ \OC::$server->getLogger()->error("Recurrence ID exists"); ++ ++ $recurrenceId = $vEvent->{'RECURRENCE-ID'}; ++ $dateTime = $recurrenceId->getValue(); ++ $recurrenceArray = explode('T', $dateTime); ++ ++ $oldVEventStart = $oldVEvent->DTSTART; ++ $oldStartDateTime = $oldVEventStart->getValue(); ++ $startDateTimeArray = explode('T', $oldStartDateTime); ++ $finalStartTime = $recurrenceArray[0] . 'T' . $startDateTimeArray[1]; ++ ++ $timeZoneId = (string) $recurrenceId['TZID']; ++ $oldVEvent->DTSTART->setDateTime( ++ new \DateTime($finalStartTime, new \DateTimeZone($timeZoneId)) ++ ); ++ ++ $oldVEventEnd = $oldVEvent->DTEND; ++ $oldEndDateTime = $oldVEventEnd->getValue(); ++ $endDateTimeArray = explode('T', $oldEndDateTime); ++ $finalEndTime = $recurrenceArray[0] . 'T' . $endDateTimeArray[1]; ++ $oldVEvent->DTEND->setDateTime( ++ new \DateTime($finalEndTime, new \DateTimeZone($timeZoneId)) ++ ); ++ } + // No changed events after all - this shouldn't happen if there is significant change yet here we are + // The scheduling status is debatable + if(empty($vEvent)) { +@@ -242,6 +267,13 @@ $data['invitee_name'] = ($senderName ?: $sender); $fromEMail = Util::getDefaultEmailAddress('invitations-noreply'); @@ -14,7 +46,7 @@ $fromName = $this->imipService->getFrom($senderName, $this->defaults->getName()); $message = $this->mailer->createMessage() -@@ -262,7 +269,22 @@ +@@ -262,7 +294,22 @@ $template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data); $template->addHeader(); @@ -38,7 +70,7 @@ $this->imipService->addBulletList($template, $vEvent, $data); // Only add response buttons to invitation requests: Fix Issue #11230 -@@ -295,7 +317,6 @@ +@@ -295,7 +342,6 @@ || in_array(strtolower($recipientDomain), $invitationLinkRecipients)) { $token = $this->imipService->createInvitationToken($iTipMessage, $vEvent, $lastOccurrence); $this->imipService->addResponseButtons($template, $token); @@ -209,14 +241,36 @@ --- ./apps/dav/lib/CalDAV/EventComparisonService.php 2024-05-06 12:46:29 +++ ./apps/dav/lib/CalDAV/EventComparisonService-new.php 2024-05-06 12:47:11 -@@ -113,7 +113,9 @@ +@@ -100,11 +100,10 @@ + unset($newEventComponents[$k]); + } + } +- ++ $sentOld = 0; + if(empty($old)) { +- return ['old' => null, 'new' => $newEventComponents]; ++ return ['old' => null, 'new' => $newEventComponents, 'sentOld' => $sentOld]; + } +- + $oldEventComponents = $old->getComponents(); + if(is_array($oldEventComponents) && !empty($oldEventComponents)) { + foreach ($oldEventComponents as $k => $event) { +@@ -113,11 +112,15 @@ continue; } if($this->removeIfUnchanged($event, $newEventComponents)) { - unset($oldEventComponents[$k]); + if($k!=1){ + unset($oldEventComponents[$k]); -+ } ++ } else { ++ $sentOld = 1; ++ } } } } + +- return ['old' => array_values($oldEventComponents), 'new' => array_values($newEventComponents)]; ++ return ['old' => array_values($oldEventComponents), 'new' => array_values($newEventComponents), 'sentOld' => $sentOld]; + } + } +\ No newline at end of file -- GitLab From 3e18422b6c463b3b9898b8b2fe58e12c6f153481 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 9 May 2024 15:59:55 +0530 Subject: [PATCH 3/6] time title added --- patches/015-email-mail-template.patch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 6cb82b72..0cdff5e3 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -102,12 +102,13 @@ + } + $data['meeting_when_html'] = ($oldMeetingWhen !== $data['meeting_when'] && $oldMeetingWhen !== null) -+ ? sprintf("%s
%s%s", $oldMeetingWhen,$timeTitle, $data['meeting_when']) +- ? sprintf("%s
%s", $oldMeetingWhen, $data['meeting_when']) ++ ? sprintf("%s
%s %s", $oldMeetingWhen,$timeTitle, $data['meeting_when']) + : $data['meeting_when']; + } else { + $data['meeting_when_html'] = + ($oldMeetingWhen !== $data['meeting_when'] && $oldMeetingWhen !== null) - ? sprintf("%s
%s", $oldMeetingWhen, $data['meeting_when']) ++ ? sprintf("%s
%s %s", $oldMeetingWhen, $this->l10n->t('Time:'),$data['meeting_when']) : $data['meeting_when']; + } } -- GitLab From 436bd38c1de677a902fc05d5d260f1b605e9efb8 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 9 May 2024 17:06:34 +0530 Subject: [PATCH 4/6] recurring banner added --- patches/015-email-mail-template.patch | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 0cdff5e3..78e4dbd8 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -1,38 +1,37 @@ --- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2024-03-18 11:18:20 +++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2024-03-11 11:18:22 -@@ -175,6 +175,31 @@ +@@ -175,6 +175,30 @@ $oldVevent = !empty($modified['old']) && is_array($modified['old']) ? array_pop($modified['old']) : null; $isModified = isset($oldVevent); -+ if (isset($vEvent->{'RECURRENCE-ID'}) && $modified['sentOld'] === 1) { -+ \OC::$server->getLogger()->error("Recurrence ID exists"); ++ if (isset($vEvent->{'RECURRENCE-ID'}) && $modified['sentOld'] === 1 && !empty($oldVevent)) { + + $recurrenceId = $vEvent->{'RECURRENCE-ID'}; + $dateTime = $recurrenceId->getValue(); + $recurrenceArray = explode('T', $dateTime); + -+ $oldVEventStart = $oldVEvent->DTSTART; ++ $oldVEventStart = $oldVevent->DTSTART; + $oldStartDateTime = $oldVEventStart->getValue(); + $startDateTimeArray = explode('T', $oldStartDateTime); + $finalStartTime = $recurrenceArray[0] . 'T' . $startDateTimeArray[1]; + + $timeZoneId = (string) $recurrenceId['TZID']; -+ $oldVEvent->DTSTART->setDateTime( ++ $oldVevent->DTSTART->setDateTime( + new \DateTime($finalStartTime, new \DateTimeZone($timeZoneId)) + ); + -+ $oldVEventEnd = $oldVEvent->DTEND; ++ $oldVEventEnd = $oldVevent->DTEND; + $oldEndDateTime = $oldVEventEnd->getValue(); + $endDateTimeArray = explode('T', $oldEndDateTime); + $finalEndTime = $recurrenceArray[0] . 'T' . $endDateTimeArray[1]; -+ $oldVEvent->DTEND->setDateTime( ++ $oldVevent->DTEND->setDateTime( + new \DateTime($finalEndTime, new \DateTimeZone($timeZoneId)) + ); + } // No changed events after all - this shouldn't happen if there is significant change yet here we are // The scheduling status is debatable if(empty($vEvent)) { -@@ -242,6 +267,13 @@ +@@ -242,6 +266,13 @@ $data['invitee_name'] = ($senderName ?: $sender); $fromEMail = Util::getDefaultEmailAddress('invitations-noreply'); @@ -46,7 +45,7 @@ $fromName = $this->imipService->getFrom($senderName, $this->defaults->getName()); $message = $this->mailer->createMessage() -@@ -262,7 +294,22 @@ +@@ -262,7 +293,22 @@ $template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data); $template->addHeader(); @@ -64,13 +63,13 @@ + $template->addHeadingBanner('#EFFFDB','#293618',$l10n->t('This recurring event has been updated, please review the information below:')); + } + $sequence = $vEvent->SEQUENCE ? $vEvent->SEQUENCE->getValue() : NULL; -+ if ($sequence && $method !== self::METHOD_CANCEL && $method !== self::METHOD_REPLY && count($vEvent)==1 && ($sequence > 2)) { ++ if (($sequence && $method !== self::METHOD_CANCEL && $method !== self::METHOD_REPLY && ($sequence > 2)) || isset($vEvent->{'RECURRENCE-ID'})) { + $template->addHeadingBanner('#EFFFDB','#293618',$l10n->t('This event has been updated, please review the information below:')); + } $this->imipService->addBulletList($template, $vEvent, $data); // Only add response buttons to invitation requests: Fix Issue #11230 -@@ -295,7 +342,6 @@ +@@ -295,7 +341,6 @@ || in_array(strtolower($recipientDomain), $invitationLinkRecipients)) { $token = $this->imipService->createInvitationToken($iTipMessage, $vEvent, $lastOccurrence); $this->imipService->addResponseButtons($template, $token); @@ -78,7 +77,6 @@ } } - --- ./apps/dav/lib/CalDAV/Schedule/IMipService.php 2024-03-18 11:40:39 +++ ./apps/dav/lib/CalDAV/Schedule/IMipService-new.php 2024-03-18 13:47:17 @@ -169,10 +169,30 @@ -- GitLab From 4a583eaf5e9777ba3079da3b3c9210a1cae1cf33 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Sun, 19 May 2024 16:20:00 +0530 Subject: [PATCH 5/6] description added --- patches/015-email-mail-template.patch | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 78e4dbd8..f5cdc880 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -1,3 +1,10 @@ +From: Avinash +Date: Friday, 17 May 2024 19:45:00 +0530 +Subject: [PATCH] In the invitation modifying a recurring event highlight whether the modification is for one occurrence or all future occurrences + + +This patch helps in indentifying that For a recurring event, the invitee knows without a doubt whether the modification pushed by the updated invitation is a one time thing or a modification of all future events. + --- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2024-03-18 11:18:20 +++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2024-03-11 11:18:22 @@ -175,6 +175,30 @@ -- GitLab From d26a7de6e176ef8c4419472c54e0b69b3401ca70 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Mon, 20 May 2024 19:03:39 +0530 Subject: [PATCH 6/6] applied suggestion --- patches/015-email-mail-template.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index f5cdc880..039ee020 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -7,13 +7,13 @@ This patch helps in indentifying that For a recurring event, the invitee knows w --- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2024-03-18 11:18:20 +++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2024-03-11 11:18:22 -@@ -175,6 +175,30 @@ +@@ -174,7 +174,29 @@ + /** @var VEvent $oldVevent */ $oldVevent = !empty($modified['old']) && is_array($modified['old']) ? array_pop($modified['old']) : null; $isModified = isset($oldVevent); - -+ if (isset($vEvent->{'RECURRENCE-ID'}) && $modified['sentOld'] === 1 && !empty($oldVevent)) { -+ -+ $recurrenceId = $vEvent->{'RECURRENCE-ID'}; +- ++ $recurrenceId = $vEvent->{'RECURRENCE-ID'}; ++ if (isset($recurrenceId) && $modified['sentOld'] === 1 && !empty($oldVevent)) { + $dateTime = $recurrenceId->getValue(); + $recurrenceArray = explode('T', $dateTime); + -- GitLab