From a72921061360525fc7e072a53ff510a1369559f9 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 7 Jul 2022 09:49:27 +0530 Subject: [PATCH 1/4] changes for email template modification on update --- patches/015-email-mail-template.patch | 205 ++++++++++++++++++-------- 1 file changed, 141 insertions(+), 64 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 6db695c7..4b6691b7 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -1,83 +1,160 @@ ---- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-04-27 09:57:34.955523100 +0530 -+++ apps/dav/lib/CalDAV/Schedule/IMipPlugin_Modifiednew.php 2022-04-27 09:57:09.345523100 +0530 -@@ -659,7 +659,7 @@ - Message $iTipMessage, $lastOccurrence) { - $token = $this->createInvitationToken($iTipMessage, $lastOccurrence); - -- $template->addBodyButtonGroup( -+ $template->addBodyButtonGroupTentative( - $l10n->t('Accept'), - $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [ - 'token' => $token, -@@ -667,18 +667,11 @@ - $l10n->t('Decline'), - $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [ - 'token' => $token, -- ]) -+ ]), -+ $l10n->t('Maybe'), -+ $this->urlGenerator->getAbsoluteUrl('apps/calendar/invitation/tentative/'.$token) - ); +--- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-07-07 09:40:41.675627600 +0530 ++++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2022-07-07 09:45:48.035627600 +0530 +@@ -151,15 +151,6 @@ + */ + public function schedule(Message $iTipMessage) { -- $moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [ -- 'token' => $token, -- ]); -- $html = vsprintf('%s', [ -- $moreOptionsURL, $l10n->t('More options …') -- ]); -- $text = $l10n->t('More options at %s', [$moreOptionsURL]); +- // Not sending any emails if the system considers the update +- // insignificant. +- if (!$iTipMessage->significantChange) { +- if (!$iTipMessage->scheduleStatus) { +- $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; +- } +- return; +- } - -- $template->addBodyText($html, $text); - } + $summary = $iTipMessage->message->VEVENT->SUMMARY; - /** + if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') { +@@ -414,7 +405,7 @@ + return false; + } ---- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-07-04 12:41:03.228533600 +0530 -+++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2022-07-04 14:42:56.208533600 +0530 -@@ -419,23 +419,33 @@ +- /** ++ /** + * @param IL10N $l10n * @param VEvent $vevent */ - private function generateWhenString(IL10N $l10n, VEvent $vevent) { -- $dtstart = $vevent->DTSTART; -- if (isset($vevent->DTEND)) { -- $dtend = $vevent->DTEND; -- } elseif (isset($vevent->DURATION)) { -- $isFloating = $vevent->DTSTART->isFloating(); -- $dtend = clone $vevent->DTSTART; +@@ -542,21 +533,57 @@ + * @param VEVENT $vevent + */ + private function addBulletList(IEMailTemplate $template, IL10N $l10n, $vevent) { +- if ($vevent->SUMMARY) { +- $template->addBodyListItem($vevent->SUMMARY, $l10n->t('Title:'), +- $this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT); + $lastmodified=0; -+ $selectedEvent = $vevent; ++ $selectedEvent = $parentevent = $vevent; + foreach( $vevent as $currentevent){ + $dtstamp= $currentevent->{'LAST-MODIFIED'}; + $dtstampTime = strtotime($dtstamp); + if($dtstampTime>$lastmodified){ + $lastmodified=$dtstampTime; + $selectedEvent = $currentevent; ++ } + } +- $meetingWhen = $this->generateWhenString($l10n, $vevent); ++ ++ if ($selectedEvent->SUMMARY) { ++ ++ if(trim($selectedEvent->SUMMARY)==trim($parentevent->SUMMARY)){ ++ $template->addBodyListItem($selectedEvent->SUMMARY, $l10n->t('Title:'), ++ $this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT); ++ }else{ ++ $template->addBodyListItemModified($selectedEvent->SUMMARY, $l10n->t('Updated Title:'), ++ $this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT); + } + } -+ $dtstart = $selectedEvent->DTSTART; -+ if (isset($selectedEvent->DTEND)) { -+ $dtend = $selectedEvent->DTEND; -+ } elseif (isset($selectedEvent->DURATION)) { -+ $isFloating = $selectedEvent->DTSTART->isFloating(); -+ $dtend = clone $selectedEvent->DTSTART; - $endDateTime = $dtend->getDateTime(); -- $endDateTime = $endDateTime->add(DateTimeParser::parse($vevent->DURATION->getValue())); -+ $endDateTime = $endDateTime->add(DateTimeParser::parse($selectedEvent->DURATION->getValue())); - $dtend->setDateTime($endDateTime, $isFloating); -- } elseif (!$vevent->DTSTART->hasTime()) { -- $isFloating = $vevent->DTSTART->isFloating(); -- $dtend = clone $vevent->DTSTART; -+ } elseif (!$selectedEvent->DTSTART->hasTime()) { -+ $isFloating = $selectedEvent->DTSTART->isFloating(); -+ $dtend = clone $selectedEvent->DTSTART; - $endDateTime = $dtend->getDateTime(); - $endDateTime = $endDateTime->modify('+1 day'); - $dtend->setDateTime($endDateTime, $isFloating); - } else { -- $dtend = clone $vevent->DTSTART; -+ $dtend = clone $selectedEvent->DTSTART; ++ $meetingWhen = $this->generateWhenString($l10n, $selectedEvent); + if ($meetingWhen) { +- $template->addBodyListItem($meetingWhen, $l10n->t('Time:'), +- $this->getAbsoluteImagePath('caldav/time.png'),'','',self::IMIP_INDENT); ++ $selectedtimestart= substr(($selectedEvent->DTSTART), strpos(($selectedEvent->DTSTART), "T") + 1); ++ $parenttimestart= substr(($parentevent->DTSTART), strpos(($parentevent->DTSTART), "T") + 1); ++ $selectedtimeend= substr(($selectedEvent->DTEND), strpos(($selectedEvent->DTEND), "T") + 1); ++ $parenttimeend= substr(($parentevent->DTEND), strpos(($parentevent->DTEND), "T") + 1); ++ ++ if(trim($selectedtimestart)==trim($parenttimestart) && trim($selectedtimeend)==trim($parenttimeend)){ ++ $template->addBodyListItem($meetingWhen, $l10n->t('Time:'), ++ $this->getAbsoluteImagePath('caldav/time.png'),'','',self::IMIP_INDENT); ++ }else{ ++ $template->addBodyListItemModified($meetingWhen, $l10n->t('Updated Time:'), ++ $this->getAbsoluteImagePath('caldav/time.png'),'','',self::IMIP_INDENT); ++ } ++ ++ + } +- if ($vevent->LOCATION) { +- $template->addBodyListItem($vevent->LOCATION, $l10n->t('Location:'), +- $this->getAbsoluteImagePath('caldav/location.png'),'','',self::IMIP_INDENT); ++ if ($selectedEvent->LOCATION) { ++ if(trim($selectedEvent->LOCATION)==trim($parentevent->LOCATION)){ ++ $template->addBodyListItem($selectedEvent->LOCATION, $l10n->t('Location:'), ++ $this->getAbsoluteImagePath('caldav/location.png'),'','',self::IMIP_INDENT); ++ }else{ ++ $template->addBodyListItemModified($selectedEvent->LOCATION, $l10n->t('Updated Location:'), ++ $this->getAbsoluteImagePath('caldav/location.png'),'','',self::IMIP_INDENT); ++ } ++ ++ } +- if ($vevent->URL) { +- $url = $vevent->URL->getValue(); ++ if ($selectedEvent->URL) { ++ $url = $selectedEvent->URL->getValue(); + $template->addBodyListItem(sprintf('%s', + htmlspecialchars($url), + htmlspecialchars($url)), +@@ -565,12 +592,18 @@ + $url,'',self::IMIP_INDENT); + } + +- $this->addAttendees($template, $l10n, $vevent); ++ $this->addAttendees($template, $l10n, $selectedEvent); + + /* Put description last, like an email body, since it can be arbitrarily long */ +- if ($vevent->DESCRIPTION) { +- $template->addBodyListItem($vevent->DESCRIPTION->getValue(), $l10n->t('Description:'), +- $this->getAbsoluteImagePath('caldav/description.png'),'','',self::IMIP_INDENT); ++ if ($selectedEvent->DESCRIPTION) { ++ if(trim($selectedEvent->DESCRIPTION)==trim($parentevent->DESCRIPTION)){ ++ $template->addBodyListItem($selectedEvent->DESCRIPTION->getValue(), $l10n->t('Description:'), ++ $this->getAbsoluteImagePath('caldav/description.png'),'','',self::IMIP_INDENT); ++ }else{ ++ $template->addBodyListItemModified($selectedEvent->DESCRIPTION, $l10n->t('Updated Description:'), ++ $this->getAbsoluteImagePath('caldav/description.png'),'','',self::IMIP_INDENT); ++ } ++ + } + } + +@@ -659,7 +692,7 @@ + Message $iTipMessage, $lastOccurrence) { + $token = $this->createInvitationToken($iTipMessage, $lastOccurrence); + +- $template->addBodyButtonGroupTentative( ++ $template->addBodyButtonGroup( + $l10n->t('Accept'), + $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [ + 'token' => $token, +@@ -667,11 +700,18 @@ + $l10n->t('Decline'), + $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [ + 'token' => $token, +- ]), +- $l10n->t('Maybe'), +- $this->urlGenerator->getAbsoluteUrl('apps/calendar/invitation/tentative/'.$token) ++ ]) + ); + ++ $moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [ ++ 'token' => $token, ++ ]); ++ $html = vsprintf('%s', [ ++ $moreOptionsURL, $l10n->t('More options …') ++ ]); ++ $text = $l10n->t('More options at %s', [$moreOptionsURL]); ++ ++ $template->addBodyText($html, $text); + } + + /** +@@ -716,4 +756,4 @@ + + return $token; + } +-} ++} +\ No newline at end of file - $isAllDay = $dtstart instanceof Property\ICalendar\Date; -- GitLab From ce1329520614848c526ca806fafda5fce291e6c4 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 7 Jul 2022 09:52:13 +0530 Subject: [PATCH 2/4] changes for email template modification on update --- patches/015-email-mail-template.patch | 3 --- 1 file changed, 3 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 4b6691b7..accc2d85 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -155,6 +155,3 @@ -} +} \ No newline at end of file - - - -- GitLab From 231bd79abcc71e74cb3f72322d6505e96704d5c8 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 7 Jul 2022 09:57:44 +0530 Subject: [PATCH 3/4] changes for email template modification on update --- patches/015-email-mail-template.patch | 41 ++++----------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index accc2d85..2fbfc462 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -1,4 +1,4 @@ ---- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-07-07 09:40:41.675627600 +0530 +--- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-07-07 09:56:28.335627600 +0530 +++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2022-07-07 09:45:48.035627600 +0530 @@ -151,15 +151,6 @@ */ @@ -41,8 +41,7 @@ + $lastmodified=$dtstampTime; + $selectedEvent = $currentevent; + } - } -- $meetingWhen = $this->generateWhenString($l10n, $vevent); ++ } + + if ($selectedEvent->SUMMARY) { + @@ -53,7 +52,8 @@ + $template->addBodyListItemModified($selectedEvent->SUMMARY, $l10n->t('Updated Title:'), + $this->getAbsoluteImagePath('caldav/title.png'),'','',self::IMIP_INDENT); + } -+ } + } +- $meetingWhen = $this->generateWhenString($l10n, $vevent); + $meetingWhen = $this->generateWhenString($l10n, $selectedEvent); if ($meetingWhen) { - $template->addBodyListItem($meetingWhen, $l10n->t('Time:'), @@ -117,38 +117,7 @@ } } -@@ -659,7 +692,7 @@ - Message $iTipMessage, $lastOccurrence) { - $token = $this->createInvitationToken($iTipMessage, $lastOccurrence); - -- $template->addBodyButtonGroupTentative( -+ $template->addBodyButtonGroup( - $l10n->t('Accept'), - $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [ - 'token' => $token, -@@ -667,11 +700,18 @@ - $l10n->t('Decline'), - $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [ - 'token' => $token, -- ]), -- $l10n->t('Maybe'), -- $this->urlGenerator->getAbsoluteUrl('apps/calendar/invitation/tentative/'.$token) -+ ]) - ); - -+ $moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [ -+ 'token' => $token, -+ ]); -+ $html = vsprintf('%s', [ -+ $moreOptionsURL, $l10n->t('More options …') -+ ]); -+ $text = $l10n->t('More options at %s', [$moreOptionsURL]); -+ -+ $template->addBodyText($html, $text); - } - - /** -@@ -716,4 +756,4 @@ +@@ -723,4 +756,4 @@ return $token; } -- GitLab From ceafde46f19a132055abe52b7bed2d0fd44396cc Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Thu, 7 Jul 2022 10:06:09 +0530 Subject: [PATCH 4/4] changes for email template modification on update --- patches/015-email-mail-template.patch | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/patches/015-email-mail-template.patch b/patches/015-email-mail-template.patch index 2fbfc462..79ac9b29 100644 --- a/patches/015-email-mail-template.patch +++ b/patches/015-email-mail-template.patch @@ -1,3 +1,37 @@ +--- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-04-27 09:57:34.955523100 +0530 ++++ apps/dav/lib/CalDAV/Schedule/IMipPlugin_Modifiednew.php 2022-04-27 09:57:09.345523100 +0530 +@@ -659,7 +659,7 @@ + Message $iTipMessage, $lastOccurrence) { + $token = $this->createInvitationToken($iTipMessage, $lastOccurrence); + +- $template->addBodyButtonGroup( ++ $template->addBodyButtonGroupTentative( + $l10n->t('Accept'), + $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [ + 'token' => $token, +@@ -667,18 +667,11 @@ + $l10n->t('Decline'), + $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [ + 'token' => $token, +- ]) ++ ]), ++ $l10n->t('Maybe'), ++ $this->urlGenerator->getAbsoluteUrl('apps/calendar/invitation/tentative/'.$token) + ); + +- $moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [ +- 'token' => $token, +- ]); +- $html = vsprintf('%s', [ +- $moreOptionsURL, $l10n->t('More options …') +- ]); +- $text = $l10n->t('More options at %s', [$moreOptionsURL]); +- +- $template->addBodyText($html, $text); + } + + /** + --- ./apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 2022-07-07 09:56:28.335627600 +0530 +++ ./apps/dav/lib/CalDAV/Schedule/IMipPlugin-new.php 2022-07-07 09:45:48.035627600 +0530 @@ -151,15 +151,6 @@ -- GitLab