# HG changeset patch # User Paul Boddie # Date 1506889931 -7200 # Node ID c3c9e3dd3213662279e11fc770c152208dca494c # Parent e63ea84b61ff4360811ecbd25c23a50be96590a8 Introduced a method to handle event versioning and sending updates. diff -r e63ea84b61ff -r c3c9e3dd3213 imiptools/client.py --- a/imiptools/client.py Sun Oct 01 17:41:21 2017 +0200 +++ b/imiptools/client.py Sun Oct 01 22:32:11 2017 +0200 @@ -727,15 +727,50 @@ """ attendee_attr = uri_dict(self.obj.get_value_map("ATTENDEE")).get(self.user) + if not attendee_attr: return None + + # Set the participation and remove any request for response indicator. + if partstat: attendee_attr["PARTSTAT"] = partstat if attendee_attr.has_key("RSVP"): del attendee_attr["RSVP"] - self.update_sender_attr(attendee_attr) + return attendee_attr + def update_event(self, changed=False): + + """ + Update the event version information and details for sending. Where + 'changed' is set to a true value for the attendee, the attendee list + will be processed and preserved; otherwise, the attendee replying will + be retained and the others removed from the object. + """ + + if self.is_organiser(): + self.update_sender() + else: + # Reply only on behalf of this user. + + attendee_attr = self.update_participation() + + if not attendee_attr: + return False + + if not changed: + self.obj["ATTENDEE"] = [(self.user, attendee_attr)] + + # Process attendee SENT-BY usage, timestamp and sequence details + # appropriately for the sender's role. + + self.update_senders() + self.update_dtstamp() + self.update_sequence() + + return True + # General message generation methods. def get_recipients(self, obj=None): @@ -968,21 +1003,9 @@ will be sent instead of a reply. """ - # Reply only on behalf of this user. - - attendee_attr = self.update_participation() - - if not attendee_attr: + if not self.update_event(changed): return False - if not changed: - self.obj["ATTENDEE"] = [(self.user, attendee_attr)] - else: - self.update_senders() - - self.update_dtstamp() - self.update_sequence() - parts = [self.object_to_part(changed and "COUNTER" or "REPLY", self.obj)] # Create and send the response. @@ -1014,10 +1037,7 @@ recurrence instances that are already stored. """ - self.update_sender() - self.update_senders() - self.update_dtstamp() - self.update_sequence() + self.update_event() if method == "REQUEST":