# HG changeset patch # User Paul Boddie # Date 1444749040 -7200 # Node ID 5942d3fcfb5d5dd7f08968d9656101cb1c3e4d1d # Parent a46e377b0b6ad2eaa7ae650e86fafbe06b745c28 Removed the command argument for outgoing-only processing, making it an instance attribute on the processing objects and setting it when initialising the person outgoing handler. diff -r a46e377b0b6a -r 5942d3fcfb5d conf/exim/30_exim4-config_people_outgoing --- a/conf/exim/30_exim4-config_people_outgoing Tue Oct 13 17:09:11 2015 +0200 +++ b/conf/exim/30_exim4-config_people_outgoing Tue Oct 13 17:10:40 2015 +0200 @@ -1,6 +1,6 @@ people_outgoing_transport: debug_print = "T: people_outgoing_transport for $local_part@$domain" driver = pipe - command = /var/lib/imip-agent/imip_person_outgoing.py -O + command = /var/lib/imip-agent/imip_person_outgoing.py user = imip-agent initgroups = true diff -r a46e377b0b6a -r 5942d3fcfb5d conf/postfix/master.cf.items --- a/conf/postfix/master.cf.items Tue Oct 13 17:09:11 2015 +0200 +++ b/conf/postfix/master.cf.items Tue Oct 13 17:10:40 2015 +0200 @@ -8,4 +8,3 @@ -o ${original_recipient} -l $lmtp_socket imip_people_outgoing unix - n n - - pipe flags=FR user=imip-agent:lmtp argv=/var/lib/imip-agent/imip_person_outgoing.py - -O diff -r a46e377b0b6a -r 5942d3fcfb5d imip_person_outgoing.py --- a/imip_person_outgoing.py Tue Oct 13 17:09:11 2015 +0200 +++ b/imip_person_outgoing.py Tue Oct 13 17:10:40 2015 +0200 @@ -4,6 +4,6 @@ from imiptools.handlers import person_outgoing from imiptools.mail import Messenger -Processor(person_outgoing.handlers)() +Processor(person_outgoing.handlers, outgoing_only=True)() # vim: tabstop=4 expandtab shiftwidth=4 diff -r a46e377b0b6a -r 5942d3fcfb5d imiptools/__init__.py --- a/imiptools/__init__.py Tue Oct 13 17:09:11 2015 +0200 +++ b/imiptools/__init__.py Tue Oct 13 17:10:40 2015 +0200 @@ -51,8 +51,9 @@ "The processing framework." - def __init__(self, handlers): + def __init__(self, handlers, outgoing_only=False): self.handlers = handlers + self.outgoing_only = outgoing_only self.messenger = None self.lmtp_socket = None self.store_dir = None @@ -66,7 +67,7 @@ def get_publisher(self): return self.publishing_dir and imip_store.FilePublisher(self.publishing_dir) or None - def process(self, f, original_recipients, outgoing_only): + def process(self, f, original_recipients): """ Process content from the stream 'f' accompanied by the given @@ -85,16 +86,18 @@ # Typically, the details of recipients are of interest in handling # messages. - if not outgoing_only: + if not self.outgoing_only: original_recipients = original_recipients or get_addresses(get_all_values(msg, "To") or []) for recipient in original_recipients: - Recipient(get_uri(recipient), messenger, store, publisher, preferences_dir, self.handlers, self.debug).process(msg, senders, outgoing_only) + Recipient(get_uri(recipient), messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug + ).process(msg, senders) # However, outgoing messages do not usually presume anything about the - # eventual recipients. + # eventual recipients and focus on the sender instead. else: - Recipient(None, messenger, store, publisher, preferences_dir, self.handlers, self.debug).process(msg, senders, outgoing_only) + Recipient(None, messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug + ).process(msg, senders) def process_args(self, args, stream): @@ -113,20 +116,14 @@ publishing_dir = [] preferences_dir = [] local_smtp = False - outgoing_only = False l = [] for arg in args: - # Detect outgoing processing mode. - - if arg == "-O": - outgoing_only = True - # Switch to collecting recipients. - elif arg == "-o": + if arg == "-o": l = original_recipients # Switch to collecting senders. @@ -170,7 +167,7 @@ self.store_dir = store_dir and store_dir[0] or None self.publishing_dir = publishing_dir and publishing_dir[0] or None self.preferences_dir = preferences_dir and preferences_dir[0] or None - self.process(stream, original_recipients, outgoing_only) + self.process(stream, original_recipients) def __call__(self): @@ -207,22 +204,24 @@ "A processor acting as a client on behalf of a recipient." - def __init__(self, user, messenger, store, publisher, preferences_dir, handlers, debug): + def __init__(self, user, messenger, store, publisher, preferences_dir, handlers, outgoing_only, debug): """ Initialise the recipient with the given 'user' identity, 'messenger', - 'store', 'publisher', 'preferences_dir', 'handlers' and 'debug' status. + 'store', 'publisher', 'preferences_dir', 'handlers', 'outgoing_only' and + 'debug' status. """ Client.__init__(self, user, messenger, store, publisher, preferences_dir) self.handlers = handlers + self.outgoing_only = outgoing_only self.debug = debug - def process(self, msg, senders, outgoing_only): + def process(self, msg, senders): """ Process the given 'msg' for a single recipient, having the given - 'senders', and with the given 'outgoing_only' status. + 'senders'. Processing individually means that contributions to resulting messages may be constructed according to individual preferences. @@ -237,11 +236,7 @@ # Check for participating recipients. Non-participating recipients will # have their messages left as being unhandled. - # Note that no user is set for outgoing messages, and so a check for - # their participation must be done in an outgoing handler once they are - # identified. - - if outgoing_only or self.is_participating(): + if self.outgoing_only or self.is_participating(): # Check for returned messages. @@ -259,7 +254,7 @@ # When processing outgoing messages, no replies or deliveries are # performed. - if outgoing_only: + if self.outgoing_only: return # Get responses from the handlers.