# HG changeset patch # User Paul Boddie # Date 1423585869 -3600 # Node ID a03710d74519c49acccd6138b052766bd5860921 # Parent 9f4fbe205b683c164137359a2866a7e31a0180fc Fixed the outgoing handler to not completely cancel events unless all attendees have been uninvited. diff -r 9f4fbe205b68 -r a03710d74519 imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Tue Feb 10 17:30:13 2015 +0100 +++ b/imiptools/handlers/person_outgoing.py Tue Feb 10 17:31:09 2015 +0100 @@ -21,7 +21,7 @@ """ from imiptools.content import Handler -from imiptools.data import uri_item +from imiptools.data import uri_dict, uri_item, uri_values from imiptools.dates import get_default_timezone from imiptools.profile import Preferences @@ -102,13 +102,30 @@ identity, attr = item - # Store the object, updating any sequence information. + # Only cancel the event completely if all attendees are given. + + obj = self.get_object(identity) - self.store.set_event(identity, self.uid, self.obj.to_node()) + attendees = uri_dict(obj.get_value_map("ATTENDEE")) + all_attendees = set(attendees.keys()) + given_attendees = set(uri_values(self.obj.get_values("ATTENDEE"))) + + if given_attendees == all_attendees: + self.store.cancel_event(identity, self.uid) - # Cancel the event. + # Otherwise, remove the given attendees and update the event. + + else: + for attendee in given_attendees: + del attendees[attendee] + obj["ATTENDEE"] = attendees.items() - self.store.cancel_event(identity, self.uid) + # Update the stored object with sequence information. + + obj["SEQUENCE"] = self.obj.get_items("SEQUENCE") + obj["DTSTAMP"] = self.obj.get_items("DTSTAMP") + + self.store.set_event(identity, self.uid, obj.to_node()) # Remove any associated request.