1.1 --- a/imiptools/__init__.py Tue Jan 27 01:29:36 2015 +0100
1.2 +++ b/imiptools/__init__.py Tue Jan 27 18:48:58 2015 +0100
1.3 @@ -66,6 +66,19 @@
1.4
1.5 # Handle messages with iTIP parts.
1.6
1.7 + for recipient in original_recipients:
1.8 + self.process_for_recipient(msg, recipient, senders, outgoing_only)
1.9 +
1.10 + def process_for_recipient(self, msg, recipient, senders, outgoing_only):
1.11 +
1.12 + """
1.13 + Process the given 'msg' for a single 'recipient', having the given
1.14 + 'senders', and with the given 'outgoing_only' status.
1.15 +
1.16 + Processing individually means that contributions to resulting messages
1.17 + may be constructed according to individual preferences.
1.18 + """
1.19 +
1.20 all_responses = []
1.21 handled = False
1.22
1.23 @@ -73,7 +86,7 @@
1.24 if part.get_content_type() in itip_content_types and \
1.25 part.get_param("method"):
1.26
1.27 - all_responses += handle_itip_part(part, senders, original_recipients, self.handlers, self.messenger)
1.28 + all_responses += handle_itip_part(part, senders, recipient, self.handlers, self.messenger)
1.29 handled = True
1.30
1.31 # When processing outgoing messages, no replies or deliveries are
1.32 @@ -112,30 +125,29 @@
1.33
1.34 # Determine whether to wrap, accompany or replace the message.
1.35
1.36 - for recipient in original_recipients:
1.37 - preferences = Preferences(get_uri(recipient))
1.38 + preferences = Preferences(get_uri(recipient))
1.39
1.40 - incoming = preferences.get("incoming")
1.41 + incoming = preferences.get("incoming")
1.42
1.43 - if incoming == "message-only":
1.44 - messages = [msg]
1.45 - else:
1.46 - summary = self.messenger.make_summary_message(msg, forwarded_parts)
1.47 - if incoming == "summary-then-message":
1.48 - messages = [summary, msg]
1.49 - elif incoming == "message-then-summary":
1.50 - messages = [msg, summary]
1.51 - elif incoming == "summary-only":
1.52 - messages = [summary]
1.53 - else: # incoming == "summary-wraps-message":
1.54 - messages = [self.messenger.wrap_message(msg, forwarded_parts)]
1.55 + if incoming == "message-only":
1.56 + messages = [msg]
1.57 + else:
1.58 + summary = self.messenger.make_summary_message(msg, forwarded_parts)
1.59 + if incoming == "summary-then-message":
1.60 + messages = [summary, msg]
1.61 + elif incoming == "message-then-summary":
1.62 + messages = [msg, summary]
1.63 + elif incoming == "summary-only":
1.64 + messages = [summary]
1.65 + else: # incoming == "summary-wraps-message":
1.66 + messages = [self.messenger.wrap_message(msg, forwarded_parts)]
1.67
1.68 - for message in messages:
1.69 - if "-d" in sys.argv:
1.70 - print >>sys.stderr, "Forwarded parts..."
1.71 - print message
1.72 - elif self.lmtp_socket:
1.73 - self.messenger.sendmail(recipient, message.as_string(), lmtp_socket=self.lmtp_socket)
1.74 + for message in messages:
1.75 + if "-d" in sys.argv:
1.76 + print >>sys.stderr, "Forwarded parts..."
1.77 + print message
1.78 + elif self.lmtp_socket:
1.79 + self.messenger.sendmail(recipient, message.as_string(), lmtp_socket=self.lmtp_socket)
1.80
1.81 # Unhandled messages are delivered as they are.
1.82
1.83 @@ -144,7 +156,7 @@
1.84 print >>sys.stderr, "Unhandled parts..."
1.85 print msg
1.86 elif self.lmtp_socket:
1.87 - self.messenger.sendmail(original_recipients, msg.as_string(), lmtp_socket=self.lmtp_socket)
1.88 + self.messenger.sendmail(recipient, msg.as_string(), lmtp_socket=self.lmtp_socket)
1.89
1.90 def process_args(self, args, stream):
1.91