# HG changeset patch # User Paul Boddie # Date 1440107538 -7200 # Node ID 7fe375ab86eccaae018e05260ad847a97bdbbdf7 # Parent 61c42a045c320ec3579876e573d48257e0beab02 Attempt to handle returned messages, avoiding their misinterpretation as messages received from other parties. diff -r 61c42a045c32 -r 7fe375ab86ec imiptools/__init__.py --- a/imiptools/__init__.py Thu Aug 20 22:45:00 2015 +0200 +++ b/imiptools/__init__.py Thu Aug 20 23:52:18 2015 +0200 @@ -227,12 +227,18 @@ for name, cls in self.handlers]) handled = False + # Check for returned messages. + for part in msg.walk(): - if part.get_content_type() in itip_content_types and \ - part.get_param("method"): + if part.get_content_type() == "message/delivery-status": + break + else: + for part in msg.walk(): + if part.get_content_type() in itip_content_types and \ + part.get_param("method"): - handle_itip_part(part, handlers) - handled = True + handle_itip_part(part, handlers) + handled = True # When processing outgoing messages, no replies or deliveries are # performed. diff -r 61c42a045c32 -r 7fe375ab86ec imiptools/handlers/person.py --- a/imiptools/handlers/person.py Thu Aug 20 22:45:00 2015 +0200 +++ b/imiptools/handlers/person.py Thu Aug 20 23:52:18 2015 +0200 @@ -152,8 +152,8 @@ "Queue a cancellation of any active event." - self._record(from_organiser=True, queue=False, cancel=True) - return self.wrap("A cancellation has been received.", link=False) + if self._record(from_organiser=True, queue=False, cancel=True): + return self.wrap("A cancellation has been received.", link=False) def counter(self): @@ -163,7 +163,7 @@ def declinecounter(self): - # NOTE: Queue a suggested modification to any active event. + # NOTE: Queue a rejected modification to any active event. return self.wrap("A declining counter proposal has been received.", link=False) @@ -171,8 +171,8 @@ "Register details of any relevant event." - self._record(from_organiser=True, queue=False) - return self.wrap("Details of an event have been received.") + if self._record(from_organiser=True, queue=False): + return self.wrap("Details of an event have been received.") def refresh(self): @@ -186,15 +186,15 @@ "Record replies and notify the recipient." - self._record(from_organiser=False, queue=False) - return self.wrap("A reply has been received.") + if self._record(from_organiser=False, queue=False): + return self.wrap("A reply has been received.") def request(self): "Hold requests and notify the recipient." - self._record(from_organiser=True, queue=True) - return self.wrap("A request has been received.") + if self._record(from_organiser=True, queue=True): + return self.wrap("A request has been received.") class Freebusy(PersonHandler, CommonFreebusy):