# HG changeset patch # User Paul Boddie # Date 1445549588 -7200 # Node ID 916dc605c2ec31e724a797f8eafb31f0c6a7e8d1 # Parent 0b6313490e797219bc839e35af080ef5d8b07f2a Prepare recipients from the object involved. Fixed "uninvitation" cancellations. diff -r 0b6313490e79 -r 916dc605c2ec imipweb/resource.py --- a/imipweb/resource.py Thu Oct 22 23:28:40 2015 +0200 +++ b/imipweb/resource.py Thu Oct 22 23:33:08 2015 +0200 @@ -223,21 +223,21 @@ # Communication methods. - def send_message(self, parts, sender, from_organiser, bcc_sender): + def send_message(self, parts, sender, obj, from_organiser, bcc_sender): """ Send the given 'parts' to the appropriate recipients, also sending a - copy to the 'sender'. The 'from_organiser' value indicates whether the - organiser is sending this message (and is thus equivalent to "as - organiser"). + copy to the 'sender'. The 'obj' together with the 'from_organiser' value + (which indicates whether the organiser is sending this message) are used + to determine the recipients of the message. """ # As organiser, send an invitation to attendees, excluding oneself if # also attending. The updated event will be saved by the outgoing # handler. - organiser = get_uri(self.obj.get_value("ORGANIZER")) - attendees = uri_values(self.obj.get_values("ATTENDEE")) + organiser = get_uri(obj.get_value("ORGANIZER")) + attendees = uri_values(obj.get_values("ATTENDEE")) if from_organiser: recipients = [get_address(attendee) for attendee in attendees if attendee != self.user] @@ -258,7 +258,8 @@ if part: parts.append(part) - self._send_message(sender, recipients, parts, bcc_sender) + if recipients or bcc_sender: + self._send_message(sender, recipients, parts, bcc_sender) def _send_message(self, sender, recipients, parts, bcc_sender): @@ -324,7 +325,7 @@ self.update_dtstamp() self.update_sequence(False) - self.send_message([self.obj.to_part(changed and "COUNTER" or "REPLY")], get_address(self.user), False, True) + self.send_message([self.obj.to_part(changed and "COUNTER" or "REPLY")], get_address(self.user), self.obj, False, True) return True def process_created_request(self, method, to_cancel=None, to_unschedule=None): @@ -359,7 +360,7 @@ # Send the updated event, along with a cancellation for each of the # unscheduled occurrences. - self.send_message(parts + unscheduled_parts, get_address(organiser), True, False) + self.send_message(parts + unscheduled_parts, get_address(organiser), self.obj, True, False) # Since the organiser can update the SEQUENCE but this can leave any # mail/calendar client lagging, issue a PUBLISH message to the @@ -381,11 +382,12 @@ # Send a cancellation to all uninvited attendees. parts = [obj.to_part("CANCEL")] - self.send_message(parts, get_address(organiser), True, False) + self.send_message(parts, get_address(organiser), obj, True, False) # Issue a CANCEL message to the user's address. - self.send_message_to_self(parts) + if method == "CANCEL": + self.send_message_to_self(parts) return True