Avoid mail notifications on superfluous changes

(cont'd)

Fixes #3790
pull/225/head
Francis Lachapelle 2016-11-03 11:47:21 -04:00
parent 42597abf8d
commit c02c4aa834
3 changed files with 52 additions and 45 deletions

View File

@ -1,24 +1,22 @@
/* /* iCalEventChanges.h - this file is part of SOPE
Copyright (C) 2004-2005 SKYRIX Software AG *
* Copyright (C) 2004-2016 Inverse inc.
This file is part of SOPE. *
* This file is free software; you can redistribute it and/or modify
SOPE is free software; you can redistribute it and/or modify it under * it under the terms of the GNU General Public License as published by
the terms of the GNU Lesser General Public License as published by the * the Free Software Foundation; either version 2, or (at your option)
Free Software Foundation; either version 2, or (at your option) any * any later version.
later version. *
* This file is distributed in the hope that it will be useful,
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY * but WITHOUT ANY WARRANTY; without even the implied warranty of
WARRANTY; without even the implied warranty of MERCHANTABILITY or * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * GNU General Public License for more details.
License for more details. *
* You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Lesser General Public * along with this program; see the file COPYING. If not, write to
License along with SOPE; see the file COPYING. If not, write to the * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA * Boston, MA 02111-1307, USA.
02111-1307, USA.
*/ */
// Created by znek on 31.08.04.
#ifndef __NGiCal_iCalEventChanges_H_ #ifndef __NGiCal_iCalEventChanges_H_
#define __NGiCal_iCalEventChanges_H_ #define __NGiCal_iCalEventChanges_H_
@ -41,6 +39,7 @@
- (id)initWithFromEvent:(iCalEvent *)_from toEvent:(iCalEvent *)_to; - (id)initWithFromEvent:(iCalEvent *)_from toEvent:(iCalEvent *)_to;
- (BOOL)hasChanges; - (BOOL)hasChanges;
- (BOOL)hasMajorChanges;
- (BOOL)hasAttendeeChanges; - (BOOL)hasAttendeeChanges;
- (NSArray *)insertedAttendees; - (NSArray *)insertedAttendees;

View File

@ -1,22 +1,21 @@
/* /* iCalEventChanges.m - this file is part of SOPE
Copyright (C) 2004-2005 SKYRIX Software AG *
* Copyright (C) 2004-2016 Inverse inc.
This file is part of SOPE. *
* This file is free software; you can redistribute it and/or modify
SOPE is free software; you can redistribute it and/or modify it under * it under the terms of the GNU General Public License as published by
the terms of the GNU Lesser General Public License as published by the * the Free Software Foundation; either version 2, or (at your option)
Free Software Foundation; either version 2, or (at your option) any * any later version.
later version. *
* This file is distributed in the hope that it will be useful,
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY * but WITHOUT ANY WARRANTY; without even the implied warranty of
WARRANTY; without even the implied warranty of MERCHANTABILITY or * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * GNU General Public License for more details.
License for more details. *
* You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Lesser General Public * along with this program; see the file COPYING. If not, write to
License along with SOPE; see the file COPYING. If not, write to the * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA * Boston, MA 02111-1307, USA.
02111-1307, USA.
*/ */
#import <Foundation/NSArray.h> #import <Foundation/NSArray.h>
@ -158,6 +157,13 @@
[self hasPropertyChanges]; [self hasPropertyChanges];
} }
- (BOOL)hasMajorChanges {
return
[self hasAttendeeChanges] ||
([self hasPropertyChanges] &&
([[self updatedProperties] count] > 1 || ![[self updatedProperties] containsObject: @"lastModified"]));
}
- (BOOL)hasAttendeeChanges { - (BOOL)hasAttendeeChanges {
return [[self insertedAttendees] count] > 0 || return [[self insertedAttendees] count] > 0 ||
[[self deletedAttendees] count] > 0 || [[self deletedAttendees] count] > 0 ||

View File

@ -891,7 +891,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
withType: @"calendar:invitation"]; withType: @"calendar:invitation"];
} }
if ([changes hasChanges]) if ([changes hasMajorChanges])
[self sendReceiptEmailForObject: newEvent [self sendReceiptEmailForObject: newEvent
addedAttendees: addedAttendees addedAttendees: addedAttendees
deletedAttendees: deletedAttendees deletedAttendees: deletedAttendees
@ -2275,11 +2275,13 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
} // if ([[newEvent attendees] count] || [[oldEvent attendees] count]) } // if ([[newEvent attendees] count] || [[oldEvent attendees] count])
else else
{ {
[self sendReceiptEmailForObject: newEvent changes = [iCalEventChanges changesFromEvent: oldEvent toEvent: newEvent];
addedAttendees: nil if ([changes hasMajorChanges])
deletedAttendees: nil [self sendReceiptEmailForObject: newEvent
updatedAttendees: nil addedAttendees: nil
operation: EventUpdated]; deletedAttendees: nil
updatedAttendees: nil
operation: EventUpdated];
} }
} // else of if (isNew) ... } // else of if (isNew) ...