# HG changeset patch # User Paul Boddie # Date 1418160586 -3600 # Node ID bc61bc5e1255f03ad7a02f3bb66220bcc67ca9b6 # Parent 39f9ea9ec85a9c261ad67691fb692e14314ff311 Remove declined events from free/busy records. diff -r 39f9ea9ec85a -r bc61bc5e1255 imiptools/content.py --- a/imiptools/content.py Tue Dec 09 00:27:14 2014 +0100 +++ b/imiptools/content.py Tue Dec 09 22:29:46 2014 +0100 @@ -192,6 +192,16 @@ return periods +def remove_from_freebusy(freebusy, attendee, uid, store): + + """ + For the given 'attendee', remove periods from 'freebusy' that are associated + with 'uid' in the 'store'. + """ + + remove_period(freebusy, uid) + store.set_freebusy(attendee, freebusy) + def update_freebusy(freebusy, attendee, periods, transp, uid, store): """ @@ -367,6 +377,9 @@ def get_periods(self): return get_periods(self.details) + def remove_from_freebusy(self, freebusy, attendee): + remove_from_freebusy(freebusy, attendee, self.uid, self.store) + def update_freebusy(self, freebusy, attendee, periods): return update_freebusy(freebusy, attendee, periods, self.get_value("TRANSP"), self.uid, self.store) diff -r 39f9ea9ec85a -r bc61bc5e1255 imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Tue Dec 09 00:27:14 2014 +0100 +++ b/imiptools/handlers/person_outgoing.py Tue Dec 09 22:29:46 2014 +0100 @@ -13,7 +13,7 @@ "Handling mechanisms specific to people." def _record(self, objtype, from_organiser=True, update_freebusy=False): - identity = self.get_value(from_organiser and "ORGANIZER" or "ATTENDEE") + identity, attr = self.get_item(from_organiser and "ORGANIZER" or "ATTENDEE") # Check for event using UID. @@ -36,7 +36,10 @@ periods = self.get_periods() freebusy = self.store.get_freebusy(identity) or [] - self.update_freebusy(freebusy, identity, periods) + if from_organiser or attr.get("PARTSTAT") == "ACCEPTED": + self.update_freebusy(freebusy, identity, periods) + else: + self.remove_from_freebusy(freebusy, identity) if self.publisher: self.publisher.set_freebusy(identity, freebusy) diff -r 39f9ea9ec85a -r bc61bc5e1255 imiptools/handlers/resource.py --- a/imiptools/handlers/resource.py Tue Dec 09 00:27:14 2014 +0100 +++ b/imiptools/handlers/resource.py Tue Dec 09 22:29:46 2014 +0100 @@ -96,8 +96,11 @@ if scheduled: self.update_freebusy(freebusy, attendee, periods) - if self.publisher: - self.publisher.set_freebusy(attendee, freebusy) + else: + self.remove_from_freebusy(freebusy, attendee) + + if self.publisher: + self.publisher.set_freebusy(attendee, freebusy) return "REPLY", to_part("REPLY", calendar)