1.1 --- a/imipweb/resource.py Thu Oct 22 23:28:40 2015 +0200
1.2 +++ b/imipweb/resource.py Thu Oct 22 23:33:08 2015 +0200
1.3 @@ -223,21 +223,21 @@
1.4
1.5 # Communication methods.
1.6
1.7 - def send_message(self, parts, sender, from_organiser, bcc_sender):
1.8 + def send_message(self, parts, sender, obj, from_organiser, bcc_sender):
1.9
1.10 """
1.11 Send the given 'parts' to the appropriate recipients, also sending a
1.12 - copy to the 'sender'. The 'from_organiser' value indicates whether the
1.13 - organiser is sending this message (and is thus equivalent to "as
1.14 - organiser").
1.15 + copy to the 'sender'. The 'obj' together with the 'from_organiser' value
1.16 + (which indicates whether the organiser is sending this message) are used
1.17 + to determine the recipients of the message.
1.18 """
1.19
1.20 # As organiser, send an invitation to attendees, excluding oneself if
1.21 # also attending. The updated event will be saved by the outgoing
1.22 # handler.
1.23
1.24 - organiser = get_uri(self.obj.get_value("ORGANIZER"))
1.25 - attendees = uri_values(self.obj.get_values("ATTENDEE"))
1.26 + organiser = get_uri(obj.get_value("ORGANIZER"))
1.27 + attendees = uri_values(obj.get_values("ATTENDEE"))
1.28
1.29 if from_organiser:
1.30 recipients = [get_address(attendee) for attendee in attendees if attendee != self.user]
1.31 @@ -258,7 +258,8 @@
1.32 if part:
1.33 parts.append(part)
1.34
1.35 - self._send_message(sender, recipients, parts, bcc_sender)
1.36 + if recipients or bcc_sender:
1.37 + self._send_message(sender, recipients, parts, bcc_sender)
1.38
1.39 def _send_message(self, sender, recipients, parts, bcc_sender):
1.40
1.41 @@ -324,7 +325,7 @@
1.42
1.43 self.update_dtstamp()
1.44 self.update_sequence(False)
1.45 - self.send_message([self.obj.to_part(changed and "COUNTER" or "REPLY")], get_address(self.user), False, True)
1.46 + self.send_message([self.obj.to_part(changed and "COUNTER" or "REPLY")], get_address(self.user), self.obj, False, True)
1.47 return True
1.48
1.49 def process_created_request(self, method, to_cancel=None, to_unschedule=None):
1.50 @@ -359,7 +360,7 @@
1.51 # Send the updated event, along with a cancellation for each of the
1.52 # unscheduled occurrences.
1.53
1.54 - self.send_message(parts + unscheduled_parts, get_address(organiser), True, False)
1.55 + self.send_message(parts + unscheduled_parts, get_address(organiser), self.obj, True, False)
1.56
1.57 # Since the organiser can update the SEQUENCE but this can leave any
1.58 # mail/calendar client lagging, issue a PUBLISH message to the
1.59 @@ -381,11 +382,12 @@
1.60 # Send a cancellation to all uninvited attendees.
1.61
1.62 parts = [obj.to_part("CANCEL")]
1.63 - self.send_message(parts, get_address(organiser), True, False)
1.64 + self.send_message(parts, get_address(organiser), obj, True, False)
1.65
1.66 # Issue a CANCEL message to the user's address.
1.67
1.68 - self.send_message_to_self(parts)
1.69 + if method == "CANCEL":
1.70 + self.send_message_to_self(parts)
1.71
1.72 return True
1.73