imip-agent

Changeset

822:5942d3fcfb5d
2015-10-13 Paul Boddie raw files shortlog changelog graph 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.
conf/exim/30_exim4-config_people_outgoing (file) conf/postfix/master.cf.items (file) imip_person_outgoing.py (file) imiptools/__init__.py (file)
     1.1 --- a/conf/exim/30_exim4-config_people_outgoing	Tue Oct 13 17:09:11 2015 +0200
     1.2 +++ b/conf/exim/30_exim4-config_people_outgoing	Tue Oct 13 17:10:40 2015 +0200
     1.3 @@ -1,6 +1,6 @@
     1.4  people_outgoing_transport:
     1.5    debug_print = "T: people_outgoing_transport for $local_part@$domain"
     1.6    driver = pipe
     1.7 -  command = /var/lib/imip-agent/imip_person_outgoing.py -O
     1.8 +  command = /var/lib/imip-agent/imip_person_outgoing.py
     1.9    user = imip-agent
    1.10    initgroups = true
     2.1 --- a/conf/postfix/master.cf.items	Tue Oct 13 17:09:11 2015 +0200
     2.2 +++ b/conf/postfix/master.cf.items	Tue Oct 13 17:10:40 2015 +0200
     2.3 @@ -8,4 +8,3 @@
     2.4    -o ${original_recipient} -l $lmtp_socket
     2.5  imip_people_outgoing  unix  -      n       n       -       -       pipe
     2.6    flags=FR user=imip-agent:lmtp argv=/var/lib/imip-agent/imip_person_outgoing.py
     2.7 -  -O
     3.1 --- a/imip_person_outgoing.py	Tue Oct 13 17:09:11 2015 +0200
     3.2 +++ b/imip_person_outgoing.py	Tue Oct 13 17:10:40 2015 +0200
     3.3 @@ -4,6 +4,6 @@
     3.4  from imiptools.handlers import person_outgoing
     3.5  from imiptools.mail import Messenger
     3.6  
     3.7 -Processor(person_outgoing.handlers)()
     3.8 +Processor(person_outgoing.handlers, outgoing_only=True)()
     3.9  
    3.10  # vim: tabstop=4 expandtab shiftwidth=4
     4.1 --- a/imiptools/__init__.py	Tue Oct 13 17:09:11 2015 +0200
     4.2 +++ b/imiptools/__init__.py	Tue Oct 13 17:10:40 2015 +0200
     4.3 @@ -51,8 +51,9 @@
     4.4  
     4.5      "The processing framework."
     4.6  
     4.7 -    def __init__(self, handlers):
     4.8 +    def __init__(self, handlers, outgoing_only=False):
     4.9          self.handlers = handlers
    4.10 +        self.outgoing_only = outgoing_only
    4.11          self.messenger = None
    4.12          self.lmtp_socket = None
    4.13          self.store_dir = None
    4.14 @@ -66,7 +67,7 @@
    4.15      def get_publisher(self):
    4.16          return self.publishing_dir and imip_store.FilePublisher(self.publishing_dir) or None
    4.17  
    4.18 -    def process(self, f, original_recipients, outgoing_only):
    4.19 +    def process(self, f, original_recipients):
    4.20  
    4.21          """
    4.22          Process content from the stream 'f' accompanied by the given
    4.23 @@ -85,16 +86,18 @@
    4.24          # Typically, the details of recipients are of interest in handling
    4.25          # messages.
    4.26  
    4.27 -        if not outgoing_only:
    4.28 +        if not self.outgoing_only:
    4.29              original_recipients = original_recipients or get_addresses(get_all_values(msg, "To") or [])
    4.30              for recipient in original_recipients:
    4.31 -                Recipient(get_uri(recipient), messenger, store, publisher, preferences_dir, self.handlers, self.debug).process(msg, senders, outgoing_only)
    4.32 +                Recipient(get_uri(recipient), messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug
    4.33 +                         ).process(msg, senders)
    4.34  
    4.35          # However, outgoing messages do not usually presume anything about the
    4.36 -        # eventual recipients.
    4.37 +        # eventual recipients and focus on the sender instead.
    4.38  
    4.39          else:
    4.40 -            Recipient(None, messenger, store, publisher, preferences_dir, self.handlers, self.debug).process(msg, senders, outgoing_only)
    4.41 +            Recipient(None, messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug
    4.42 +                     ).process(msg, senders)
    4.43  
    4.44      def process_args(self, args, stream):
    4.45  
    4.46 @@ -113,20 +116,14 @@
    4.47          publishing_dir = []
    4.48          preferences_dir = []
    4.49          local_smtp = False
    4.50 -        outgoing_only = False
    4.51  
    4.52          l = []
    4.53  
    4.54          for arg in args:
    4.55  
    4.56 -            # Detect outgoing processing mode.
    4.57 -
    4.58 -            if arg == "-O":
    4.59 -                outgoing_only = True
    4.60 -
    4.61              # Switch to collecting recipients.
    4.62  
    4.63 -            elif arg == "-o":
    4.64 +            if arg == "-o":
    4.65                  l = original_recipients
    4.66  
    4.67              # Switch to collecting senders.
    4.68 @@ -170,7 +167,7 @@
    4.69          self.store_dir = store_dir and store_dir[0] or None
    4.70          self.publishing_dir = publishing_dir and publishing_dir[0] or None
    4.71          self.preferences_dir = preferences_dir and preferences_dir[0] or None
    4.72 -        self.process(stream, original_recipients, outgoing_only)
    4.73 +        self.process(stream, original_recipients)
    4.74  
    4.75      def __call__(self):
    4.76  
    4.77 @@ -207,22 +204,24 @@
    4.78  
    4.79      "A processor acting as a client on behalf of a recipient."
    4.80  
    4.81 -    def __init__(self, user, messenger, store, publisher, preferences_dir, handlers, debug):
    4.82 +    def __init__(self, user, messenger, store, publisher, preferences_dir, handlers, outgoing_only, debug):
    4.83  
    4.84          """
    4.85          Initialise the recipient with the given 'user' identity, 'messenger',
    4.86 -        'store', 'publisher', 'preferences_dir', 'handlers' and 'debug' status.
    4.87 +        'store', 'publisher', 'preferences_dir', 'handlers', 'outgoing_only' and
    4.88 +        'debug' status.
    4.89          """
    4.90  
    4.91          Client.__init__(self, user, messenger, store, publisher, preferences_dir)
    4.92          self.handlers = handlers
    4.93 +        self.outgoing_only = outgoing_only
    4.94          self.debug = debug
    4.95  
    4.96 -    def process(self, msg, senders, outgoing_only):
    4.97 +    def process(self, msg, senders):
    4.98  
    4.99          """
   4.100          Process the given 'msg' for a single recipient, having the given
   4.101 -        'senders', and with the given 'outgoing_only' status.
   4.102 +        'senders'.
   4.103  
   4.104          Processing individually means that contributions to resulting messages
   4.105          may be constructed according to individual preferences.
   4.106 @@ -237,11 +236,7 @@
   4.107          # Check for participating recipients. Non-participating recipients will
   4.108          # have their messages left as being unhandled.
   4.109  
   4.110 -        # Note that no user is set for outgoing messages, and so a check for
   4.111 -        # their participation must be done in an outgoing handler once they are
   4.112 -        # identified.
   4.113 -
   4.114 -        if outgoing_only or self.is_participating():
   4.115 +        if self.outgoing_only or self.is_participating():
   4.116  
   4.117              # Check for returned messages.
   4.118  
   4.119 @@ -259,7 +254,7 @@
   4.120          # When processing outgoing messages, no replies or deliveries are
   4.121          # performed.
   4.122  
   4.123 -        if outgoing_only:
   4.124 +        if self.outgoing_only:
   4.125              return
   4.126  
   4.127          # Get responses from the handlers.