Skip to content

Commit 2cf12e0

Browse files
author
Eddie Parker
committed
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. :))
1 parent 00de271 commit 2cf12e0

File tree

4 files changed

+95
-8
lines changed

4 files changed

+95
-8
lines changed

doc/upgrading.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,35 @@ accordingly. Note that there is information about upgrade procedures in the
88

99
.. contents::
1010

11+
12+
13+
Migrating from 0.7 to 0.8
14+
=========================
15+
16+
0.8.0 Added Dispatcher role
17+
---------------------------
18+
19+
A new config option has been added. There is a 'role' that can be filled,
20+
that of the 'dispatcher'. This person acts as a central sentinel for issues
21+
coming into the system. You can configure it so that all e-mail error messages
22+
get bounced to them, them and the user in question, or just the user (default).
23+
24+
To toggle these switches, look at the new classic and minimal config.py's,
25+
specifically:
26+
27+
28+
# The 'dispatcher' is a role that can get notified of new items to the database.
29+
DISPATCHER_EMAIL = ADMIN_EMAIL
30+
31+
...
32+
33+
34+
# Send error messages to the dispatcher, user, or both?
35+
# If 'dispatcher', error message notifications will only be sent to the dispatcher.
36+
# If 'user', error message notifications will only be sent to the user.
37+
# If 'both', error message notifications will be sent to both individuals.
38+
ERROR_MESSAGES_TO = 'user'
39+
1140
Migrating from 0.6 to 0.7
1241
=========================
1342

roundup/mailgw.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class node. Any parts of other types are each stored in separate files
7272
an exception, the original message is bounced back to the sender with the
7373
explanatory message given in the exception.
7474
75-
$Id: mailgw.py,v 1.143 2004-02-11 23:55:08 richard Exp $
75+
$Id: mailgw.py,v 1.144 2004-03-25 19:27:15 eparker Exp $
7676
"""
7777
__docformat__ = 'restructuredtext'
7878

@@ -429,13 +429,27 @@ def handle_Message(self, message):
429429
"""
430430
# in some rare cases, a particularly stuffed-up e-mail will make
431431
# its way into here... try to handle it gracefully
432+
433+
# Setting the dispatcher e-mail here, so as not to clutter things. Defaulting to ADMIN_EMAIL, if not set.
434+
dispatcherEmail = getattr(self.instance.config, "DISPATCHER_EMAIL", getattr(self.instance.config, "ADMIN_EMAIL"))
435+
errorMessagesTo = getattr(self.instance.config, "ERROR_MESSAGES_TO", "user")
436+
432437
sendto = message.getaddrlist('resent-from')
433438
if not sendto:
434439
sendto = message.getaddrlist('from')
435440
if not sendto:
436441
# very bad-looking message - we don't even know who sent it
437442
# XXX we should use a log file here...
438-
sendto = [self.instance.config.ADMIN_EMAIL]
443+
444+
# [EP] This section was originally only to admin.. Not sure if this should ever go to the user?
445+
446+
if(errorMessagesTo == "dispatcher"):
447+
sendto = [dispatcherEmail]
448+
elif(errorMessagesTo == "both"):
449+
sendto = [dispatcherEmail, self.instance.config.ADMIN_EMAIL]
450+
else:
451+
sendto = [self.instance.config.ADMIN_EMAIL]
452+
439453
m = ['Subject: badly formed message from mail gateway']
440454
m.append('')
441455
m.append('The mail gateway retrieved a message which has no From:')
@@ -454,7 +468,13 @@ def handle_Message(self, message):
454468
except MailUsageHelp:
455469
# bounce the message back to the sender with the usage message
456470
fulldoc = '\n'.join(string.split(__doc__, '\n')[2:])
457-
sendto = [sendto[0][1]]
471+
if(errorMessagesTo == "dispatcher"):
472+
sendto = [dispatcherEmail]
473+
elif(errorMessagesTo == "both"):
474+
sendto = [dispatcherEmail, sendto[0][1]]
475+
else:
476+
sendto = [sendto[0][1]]
477+
458478
m = ['']
459479
m.append('\n\nMail Gateway Help\n=================')
460480
m.append(fulldoc)
@@ -463,15 +483,27 @@ def handle_Message(self, message):
463483
except MailUsageError, value:
464484
# bounce the message back to the sender with the usage message
465485
fulldoc = '\n'.join(string.split(__doc__, '\n')[2:])
466-
sendto = [sendto[0][1]]
486+
487+
if(errorMessagesTo == "dispatcher"):
488+
sendto = [dispatcherEmail]
489+
elif(errorMessagesTo == "both"):
490+
sendto = [dispatcherEmail, sendto[0][1]]
491+
else:
492+
sendto = [sendto[0][1]]
467493
m = ['']
468494
m.append(str(value))
469495
m.append('\n\nMail Gateway Help\n=================')
470496
m.append(fulldoc)
471497
self.mailer.bounce_message(message, sendto, m)
472498
except Unauthorized, value:
473499
# just inform the user that he is not authorized
474-
sendto = [sendto[0][1]]
500+
501+
if(errorMessagesTo == "dispatcher"):
502+
sendto = [dispatcherEmail]
503+
elif(errorMessagesTo == "both"):
504+
sendto = [dispatcherEmail, sendto[0][1]]
505+
else:
506+
sendto = [sendto[0][1]]
475507
m = ['']
476508
m.append(str(value))
477509
self.mailer.bounce_message(message, sendto, m)
@@ -483,7 +515,14 @@ def handle_Message(self, message):
483515
except:
484516
# bounce the message back to the sender with the error message
485517
# XXX we should use a log file here...
486-
sendto = [sendto[0][1], self.instance.config.ADMIN_EMAIL]
518+
519+
if(errorMessagesTo == "dispatcher"):
520+
sendto = [dispatcherEmail]
521+
elif(errorMessagesTo == "both"):
522+
sendto = [dispatcherEmail, sendto[0][1], self.instance.config.ADMIN_EMAIL]
523+
else:
524+
sendto = [sendto[0][1], self.instance.config.ADMIN_EMAIL]
525+
487526
m = ['']
488527
m.append('An unexpected error occurred during the processing')
489528
m.append('of your message. The tracker administrator is being')

templates/classic/config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: config.py,v 1.5 2004-02-23 05:29:05 richard Exp $
18+
# $Id: config.py,v 1.6 2004-03-25 19:27:15 eparker Exp $
1919

2020
import os
2121

@@ -63,6 +63,9 @@
6363
# The email address that roundup will complain to if it runs into trouble
6464
ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
6565

66+
# The 'dispatcher' is a role that can get notified of new items to the database.
67+
DISPATCHER_EMAIL = ADMIN_EMAIL
68+
6669
# Additional text to include in the "name" part of the From: address used
6770
# in nosy messages. If the sending user is "Foo Bar", the From: line is
6871
# usually:
@@ -71,6 +74,13 @@
7174
# "Foo Bar EMAIL_FROM_TAG" <[email protected]>
7275
EMAIL_FROM_TAG = ""
7376

77+
78+
# Send error messages to the dispatcher, user, or both?
79+
# If 'dispatcher', error message notifications will only be sent to the dispatcher.
80+
# If 'user', error message notifications will only be sent to the user.
81+
# If 'both', error message notifications will be sent to both individuals.
82+
ERROR_MESSAGES_TO = 'user'
83+
7484
# Send nosy messages to the author of the message?
7585
# If 'new' is used, then the author will only be sent the message when the
7686
# message creates a new issue. If 'yes' then the author will always be sent

templates/minimal/config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: config.py,v 1.4 2004-02-23 05:29:06 richard Exp $
18+
# $Id: config.py,v 1.5 2004-03-25 19:27:15 eparker Exp $
1919

2020
import os
2121

@@ -63,6 +63,9 @@
6363
# The email address that roundup will complain to if it runs into trouble
6464
ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
6565

66+
# The 'dispatcher' is a role that can get notified of new items to the database.
67+
DISPATCHER_EMAIL = ADMIN_EMAIL
68+
6669
# Additional text to include in the "name" part of the From: address used
6770
# in nosy messages. If the sending user is "Foo Bar", the From: line is
6871
# usually: "Foo Bar" <[email protected]>
@@ -78,6 +81,12 @@
7881
NEW_WEB_USER_ROLES = 'User'
7982
NEW_EMAIL_USER_ROLES = 'User'
8083

84+
# Send error messages to the dispatcher, user, or both?
85+
# If 'dispatcher', error message notifications will only be sent to the dispatcher.
86+
# If 'user', error message notifications will only be sent to the user.
87+
# If 'both', error message notifications will be sent to both individuals.
88+
ERROR_MESSAGES_TO = 'user'
89+
8190
# Send nosy messages to the author of the message
8291
MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no'
8392

0 commit comments

Comments
 (0)