From: eparker Date: Thu, 25 Mar 2004 19:27:15 +0000 (+0000) Subject: Added the ability to toggle where error messages go. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=86aff8e3cb45b8c928dfa6593922993c7050e04a;p=roundup.git Added the ability to toggle where error messages go. They either go to the user (default, for backwards compatibility), the dispatcher, or both. These are able to be toggled via settings in config.py. Please refer to upgrading.txt for more details. (And Richard, let me know if I've done anything wrong with this checkin. :)) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2187 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/doc/upgrading.txt b/doc/upgrading.txt index 2a20dc7..dbd01ad 100644 --- a/doc/upgrading.txt +++ b/doc/upgrading.txt @@ -8,6 +8,35 @@ accordingly. Note that there is information about upgrade procedures in the .. contents:: + + +Migrating from 0.7 to 0.8 +========================= + +0.8.0 Added Dispatcher role +--------------------------- + +A new config option has been added. There is a 'role' that can be filled, +that of the 'dispatcher'. This person acts as a central sentinel for issues +coming into the system. You can configure it so that all e-mail error messages +get bounced to them, them and the user in question, or just the user (default). + +To toggle these switches, look at the new classic and minimal config.py's, +specifically: + + +# The 'dispatcher' is a role that can get notified of new items to the database. +DISPATCHER_EMAIL = ADMIN_EMAIL + +... + + +# Send error messages to the dispatcher, user, or both? +# If 'dispatcher', error message notifications will only be sent to the dispatcher. +# If 'user', error message notifications will only be sent to the user. +# If 'both', error message notifications will be sent to both individuals. +ERROR_MESSAGES_TO = 'user' + Migrating from 0.6 to 0.7 ========================= diff --git a/roundup/mailgw.py b/roundup/mailgw.py index f45eedc..6b1fb93 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -72,7 +72,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.143 2004-02-11 23:55:08 richard Exp $ +$Id: mailgw.py,v 1.144 2004-03-25 19:27:15 eparker Exp $ """ __docformat__ = 'restructuredtext' @@ -429,13 +429,27 @@ class MailGW: """ # in some rare cases, a particularly stuffed-up e-mail will make # its way into here... try to handle it gracefully + + # Setting the dispatcher e-mail here, so as not to clutter things. Defaulting to ADMIN_EMAIL, if not set. + dispatcherEmail = getattr(self.instance.config, "DISPATCHER_EMAIL", getattr(self.instance.config, "ADMIN_EMAIL")) + errorMessagesTo = getattr(self.instance.config, "ERROR_MESSAGES_TO", "user") + sendto = message.getaddrlist('resent-from') if not sendto: sendto = message.getaddrlist('from') if not sendto: # very bad-looking message - we don't even know who sent it # XXX we should use a log file here... - sendto = [self.instance.config.ADMIN_EMAIL] + + # [EP] This section was originally only to admin.. Not sure if this should ever go to the user? + + if(errorMessagesTo == "dispatcher"): + sendto = [dispatcherEmail] + elif(errorMessagesTo == "both"): + sendto = [dispatcherEmail, self.instance.config.ADMIN_EMAIL] + else: + sendto = [self.instance.config.ADMIN_EMAIL] + m = ['Subject: badly formed message from mail gateway'] m.append('') m.append('The mail gateway retrieved a message which has no From:') @@ -454,7 +468,13 @@ class MailGW: except MailUsageHelp: # bounce the message back to the sender with the usage message fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) - sendto = [sendto[0][1]] + if(errorMessagesTo == "dispatcher"): + sendto = [dispatcherEmail] + elif(errorMessagesTo == "both"): + sendto = [dispatcherEmail, sendto[0][1]] + else: + sendto = [sendto[0][1]] + m = [''] m.append('\n\nMail Gateway Help\n=================') m.append(fulldoc) @@ -463,7 +483,13 @@ class MailGW: except MailUsageError, value: # bounce the message back to the sender with the usage message fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) - sendto = [sendto[0][1]] + + if(errorMessagesTo == "dispatcher"): + sendto = [dispatcherEmail] + elif(errorMessagesTo == "both"): + sendto = [dispatcherEmail, sendto[0][1]] + else: + sendto = [sendto[0][1]] m = [''] m.append(str(value)) m.append('\n\nMail Gateway Help\n=================') @@ -471,7 +497,13 @@ class MailGW: self.mailer.bounce_message(message, sendto, m) except Unauthorized, value: # just inform the user that he is not authorized - sendto = [sendto[0][1]] + + if(errorMessagesTo == "dispatcher"): + sendto = [dispatcherEmail] + elif(errorMessagesTo == "both"): + sendto = [dispatcherEmail, sendto[0][1]] + else: + sendto = [sendto[0][1]] m = [''] m.append(str(value)) self.mailer.bounce_message(message, sendto, m) @@ -483,7 +515,14 @@ class MailGW: except: # bounce the message back to the sender with the error message # XXX we should use a log file here... - sendto = [sendto[0][1], self.instance.config.ADMIN_EMAIL] + + if(errorMessagesTo == "dispatcher"): + sendto = [dispatcherEmail] + elif(errorMessagesTo == "both"): + sendto = [dispatcherEmail, sendto[0][1], self.instance.config.ADMIN_EMAIL] + else: + sendto = [sendto[0][1], self.instance.config.ADMIN_EMAIL] + m = [''] m.append('An unexpected error occurred during the processing') m.append('of your message. The tracker administrator is being') diff --git a/templates/classic/config.py b/templates/classic/config.py index f536784..703fc14 100644 --- a/templates/classic/config.py +++ b/templates/classic/config.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: config.py,v 1.5 2004-02-23 05:29:05 richard Exp $ +# $Id: config.py,v 1.6 2004-03-25 19:27:15 eparker Exp $ import os @@ -63,6 +63,9 @@ TRACKER_WEB = 'http://tracker.example/cgi-bin/roundup.cgi/bugs/' # The email address that roundup will complain to if it runs into trouble ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN +# The 'dispatcher' is a role that can get notified of new items to the database. +DISPATCHER_EMAIL = ADMIN_EMAIL + # Additional text to include in the "name" part of the From: address used # in nosy messages. If the sending user is "Foo Bar", the From: line is # usually: @@ -71,6 +74,13 @@ ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN # "Foo Bar EMAIL_FROM_TAG" EMAIL_FROM_TAG = "" + +# Send error messages to the dispatcher, user, or both? +# If 'dispatcher', error message notifications will only be sent to the dispatcher. +# If 'user', error message notifications will only be sent to the user. +# If 'both', error message notifications will be sent to both individuals. +ERROR_MESSAGES_TO = 'user' + # Send nosy messages to the author of the message? # If 'new' is used, then the author will only be sent the message when the # message creates a new issue. If 'yes' then the author will always be sent diff --git a/templates/minimal/config.py b/templates/minimal/config.py index cf82f22..7b2807e 100644 --- a/templates/minimal/config.py +++ b/templates/minimal/config.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: config.py,v 1.4 2004-02-23 05:29:06 richard Exp $ +# $Id: config.py,v 1.5 2004-03-25 19:27:15 eparker Exp $ import os @@ -63,6 +63,9 @@ TRACKER_WEB = 'http://tracker.example/cgi-bin/roundup.cgi/bugs/' # The email address that roundup will complain to if it runs into trouble ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN +# The 'dispatcher' is a role that can get notified of new items to the database. +DISPATCHER_EMAIL = ADMIN_EMAIL + # Additional text to include in the "name" part of the From: address used # in nosy messages. If the sending user is "Foo Bar", the From: line is # usually: "Foo Bar" @@ -78,6 +81,12 @@ EMAIL_FROM_TAG = "" NEW_WEB_USER_ROLES = 'User' NEW_EMAIL_USER_ROLES = 'User' +# Send error messages to the dispatcher, user, or both? +# If 'dispatcher', error message notifications will only be sent to the dispatcher. +# If 'user', error message notifications will only be sent to the user. +# If 'both', error message notifications will be sent to both individuals. +ERROR_MESSAGES_TO = 'user' + # Send nosy messages to the author of the message MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no'