# HG changeset patch # User Paul Boddie # Date 1444746439 -7200 # Node ID ce9444ff5b55ac22190ab9cec987261a5ee44f8b # Parent 86d401e6e30ab1c610619c6b7ac3139a8fe13063 Removed postponed identity setting for outgoing messages, using the sender details instead. 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 86d401e6e30a -r ce9444ff5b55 conf/exim/30_exim4-config_people_outgoing --- a/conf/exim/30_exim4-config_people_outgoing Mon Oct 12 23:53:38 2015 +0200 +++ b/conf/exim/30_exim4-config_people_outgoing Tue Oct 13 16:27:19 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 86d401e6e30a -r ce9444ff5b55 conf/postfix/master.cf.items --- a/conf/postfix/master.cf.items Mon Oct 12 23:53:38 2015 +0200 +++ b/conf/postfix/master.cf.items Tue Oct 13 16:27:19 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 86d401e6e30a -r ce9444ff5b55 imip_person_outgoing.py --- a/imip_person_outgoing.py Mon Oct 12 23:53:38 2015 +0200 +++ b/imip_person_outgoing.py Tue Oct 13 16:27:19 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 86d401e6e30a -r ce9444ff5b55 imiptools/__init__.py --- a/imiptools/__init__.py Mon Oct 12 23:53:38 2015 +0200 +++ b/imiptools/__init__.py Tue Oct 13 16:27:19 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 @@ -75,6 +76,7 @@ msg = message_from_file(f) senders = get_addresses(get_all_values(msg, "Reply-To") or get_all_values(msg, "From") or []) + sender = (get_all_values(msg, "From") or [None])[0] messenger = self.messenger store = self.get_store() @@ -85,16 +87,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(get_uri(sender), messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug + ).process(msg, senders) def process_args(self, args, stream): @@ -113,20 +117,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 +168,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 +205,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 +237,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.is_participating(): # Check for returned messages. @@ -259,7 +255,7 @@ # When processing outgoing messages, no replies or deliveries are # performed. - if outgoing_only: + if self.outgoing_only: return # Get responses from the handlers. diff -r 86d401e6e30a -r ce9444ff5b55 imiptools/client.py --- a/imiptools/client.py Mon Oct 12 23:53:38 2015 +0200 +++ b/imiptools/client.py Tue Oct 13 16:27:19 2015 +0200 @@ -282,17 +282,6 @@ self.sequence = obj and self.obj.get_value("SEQUENCE") self.dtstamp = obj and self.obj.get_value("DTSTAMP") - def set_identity(self, method): - - """ - Set the current user for the current object in the context of the given - 'method'. It is usually set when initialising the handler, using the - recipient details, but outgoing messages do not reference the recipient - in this way. - """ - - pass - def is_usable(self, method=None): "Return whether the current object is usable with the given 'method'." diff -r 86d401e6e30a -r ce9444ff5b55 imiptools/content.py --- a/imiptools/content.py Mon Oct 12 23:53:38 2015 +0200 +++ b/imiptools/content.py Tue Oct 13 16:27:19 2015 +0200 @@ -69,7 +69,6 @@ # Dispatch to a handler and obtain any response. handler.set_object(Object({name : item})) - handler.set_identity(method) if handler.is_usable(method): diff -r 86d401e6e30a -r ce9444ff5b55 imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Mon Oct 12 23:53:38 2015 +0200 +++ b/imiptools/handlers/person_outgoing.py Tue Oct 13 16:27:19 2015 +0200 @@ -29,26 +29,10 @@ "Handling mechanisms specific to people." - def set_identity(self, method): - - """ - Set the current user for the current object in the context of the given - 'method'. It is usually set when initialising the handler, using the - recipient details, but outgoing messages do not reference the recipient - in this way. - """ - - if self.obj: - from_organiser = method in self.organiser_methods - self.user = get_uri(self.obj.get_value(from_organiser and "ORGANIZER" or "ATTENDEE")) - def _add(self): "Add a recurrence for the current object." - if not Client.is_participating(self): - return False - # Obtain valid organiser and attendee details. oa = self.require_organiser_and_attendees() @@ -83,9 +67,6 @@ from an organiser if 'from_organiser' is set to a true value. """ - if not Client.is_participating(self): - return False - # Check for a new event, tolerating not-strictly-new events if the # attendee is responding. @@ -141,9 +122,6 @@ from an organiser if 'from_organiser' is set to a true value. """ - if not Client.is_participating(self): - return False - # Check for event using UID. if not self.have_new_object(): @@ -210,9 +188,6 @@ "Remove any counter-proposals for the given event." - if not Client.is_participating(self): - return False - # Check for event using UID. if not self.have_new_object():