From 3388c1846694f616dafd6db9a0647de68b338fec Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 12 Aug 2021 11:59:41 -0400 Subject: [PATCH] chore(sogo-ealarms-notify): fix handling of alarms on tasks Fixes #5158 --- .../Appointments/SOGoAptMailNotification.m | 26 ++++++++++++------- SoObjects/Appointments/SOGoAptMailReminder.h | 1 + SoObjects/Appointments/SOGoAptMailReminder.m | 13 +++++++--- Tools/SOGoEAlarmsNotifier.m | 5 +--- .../Appointments/SOGoAptMailReminder.wox | 5 ++-- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/SoObjects/Appointments/SOGoAptMailNotification.m b/SoObjects/Appointments/SOGoAptMailNotification.m index c3c125522..a84e26a85 100644 --- a/SoObjects/Appointments/SOGoAptMailNotification.m +++ b/SoObjects/Appointments/SOGoAptMailNotification.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2020 Inverse inc. + Copyright (C) 2006-2021 Inverse inc. Copyright (C) 2000-2005 SKYRIX Software AG This file is part of SOGo. @@ -106,7 +106,8 @@ if (!oldStartDate) { ASSIGN (oldStartDate, [[self previousApt] startDate]); - if (![(iCalEvent*)[self previousApt] isAllDay]) + if ([[self previousApt] isKindOfClass: [iCalToDo class]] || + ![(iCalEvent*)[self previousApt] isAllDay]) [oldStartDate setTimeZone: viewTZ]; } return oldStartDate; @@ -117,7 +118,8 @@ if (!newStartDate) { ASSIGN (newStartDate, [[self apt] startDate]); - if (![(iCalEvent*)[self apt] isAllDay]) + if ([[self apt] isKindOfClass: [iCalToDo class]] || + ![(iCalEvent*)[self apt] isAllDay]) [newStartDate setTimeZone: viewTZ]; } return newStartDate; @@ -134,12 +136,15 @@ endDate = [(iCalEvent*)[self previousApt] endDate]; if ([(iCalEvent*)[self previousApt] isAllDay]) endDate = [endDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:-1]; + else + [endDate setTimeZone: viewTZ]; ASSIGN (oldEndDate, endDate); } else - ASSIGN (oldEndDate, [(iCalToDo*)[self previousApt] due]); - if (![(iCalEvent*)[self previousApt] isAllDay]) - [oldEndDate setTimeZone: viewTZ]; + { + ASSIGN (oldEndDate, [(iCalToDo*)[self previousApt] due]); + [oldEndDate setTimeZone: viewTZ]; + } } return oldEndDate; } @@ -155,12 +160,15 @@ endDate = [(iCalEvent*)[self apt] endDate]; if ([(iCalEvent*)[self apt] isAllDay]) endDate = [endDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:-1]; + else + [endDate setTimeZone: viewTZ]; ASSIGN (newEndDate, endDate); } else - ASSIGN (newEndDate, [(iCalToDo*)[self apt] due]); - if (![(iCalEvent*)[self apt] isAllDay]) - [newEndDate setTimeZone: viewTZ]; + { + ASSIGN (newEndDate, [(iCalToDo*)[self apt] due]); + [newEndDate setTimeZone: viewTZ]; + } } return newEndDate; } diff --git a/SoObjects/Appointments/SOGoAptMailReminder.h b/SoObjects/Appointments/SOGoAptMailReminder.h index 724e2ec7c..56eb5aa49 100644 --- a/SoObjects/Appointments/SOGoAptMailReminder.h +++ b/SoObjects/Appointments/SOGoAptMailReminder.h @@ -24,6 +24,7 @@ - (NSString *) aptSummary; - (NSString *) aptStartDate; +- (NSString *) aptEndDate; - (NSString *) calendarName; - (iCalPerson *) organizer; diff --git a/SoObjects/Appointments/SOGoAptMailReminder.m b/SoObjects/Appointments/SOGoAptMailReminder.m index bb8140680..b2c08ec57 100644 --- a/SoObjects/Appointments/SOGoAptMailReminder.m +++ b/SoObjects/Appointments/SOGoAptMailReminder.m @@ -56,10 +56,17 @@ static NSCharacterSet *wsSet = nil; - (void) setupValues { + NSString *formattedDate; + [super setupValues]; - [values setObject: [self aptStartDate] - forKey: @"StartDate"]; + formattedDate = [self aptStartDate]; + if (![formattedDate length]) + // Task with a due date + formattedDate = [self aptEndDate]; + if ([formattedDate length]) + [values setObject: formattedDate + forKey: @"StartDate"]; } - (NSString *) getBody @@ -112,7 +119,7 @@ static NSCharacterSet *wsSet = nil; [self setupValues]; s = [self labelForKey: @"Reminder: \"%{Summary}\" - %{StartDate}" - inContext: context]; + inContext: context]; return [values keysWithFormat: s]; } diff --git a/Tools/SOGoEAlarmsNotifier.m b/Tools/SOGoEAlarmsNotifier.m index ac80c6a4e..7abe3397e 100644 --- a/Tools/SOGoEAlarmsNotifier.m +++ b/Tools/SOGoEAlarmsNotifier.m @@ -158,7 +158,6 @@ WOContext *localContext; WOApplication *app; SOGoAptMailReminder *p; - NSString *pageName; WOResourceManager *rm; SOGoAppointmentFolders *folders; @@ -188,9 +187,7 @@ folders = [userFolder privateCalendars: @"Calendar" inContext: localContext]; - pageName = [NSString stringWithFormat: @"SOGoAptMail%@", @"Reminder"]; - - p = [app pageWithName: pageName inContext: localContext]; + p = [app pageWithName: @"SOGoAptMailReminder" inContext: localContext]; parts = [containerPath componentsSeparatedByString: @"/"]; if ([parts count] > 4) diff --git a/UI/Templates/Appointments/SOGoAptMailReminder.wox b/UI/Templates/Appointments/SOGoAptMailReminder.wox index 1d04e678d..b2b55cd02 100644 --- a/UI/Templates/Appointments/SOGoAptMailReminder.wox +++ b/UI/Templates/Appointments/SOGoAptMailReminder.wox @@ -29,10 +29,11 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon - + - +