# HG changeset patch # User Paul Boddie # Date 1507059364 -7200 # Node ID cee37b136bac67e0bd4b221c8b2221f98e8c7d0e # Parent 6b29d8a60136a5bcaa54e9e5ff39c7497368732b Introduced a dedicated response message generating method. diff -r 6b29d8a60136 -r cee37b136bac imiptools/client.py --- a/imiptools/client.py Mon Oct 02 21:42:42 2017 +0200 +++ b/imiptools/client.py Tue Oct 03 21:36:04 2017 +0200 @@ -967,6 +967,18 @@ parts = [self.object_to_part("CANCEL", obj)] return self.make_message_for_self(parts) + def make_response_message(self, recipients, changed=False): + + """ + Prepare a response to 'recipients' for the current object with the + indicated 'changed' state. + """ + + # NOTE: Might need updating to include rescheduled objects. + + parts = [self.object_to_part(changed and "COUNTER" or "REPLY", self.obj)] + return self.make_message(parts, recipients, bcc_sender=True) + # Action methods. def process_declined_counter(self, attendee): @@ -1006,12 +1018,10 @@ if not self.update_event(changed): return False - parts = [self.object_to_part(changed and "COUNTER" or "REPLY", self.obj)] - # Create and send the response. recipients = self.get_recipients() - message = self.make_message(parts, recipients, bcc_sender=True) + message = self.make_response_message(recipients, changed) self.send_message(message, recipients, bcc_sender=True) return True