diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py
index bce531513554842af812c949173a08c2421fe94e..f870bb99a0e4b75e60accffc5d66b1dfdebaf2f5 100644 (file)
--- a/roundup/roundupdb.py
+++ b/roundup/roundupdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: roundupdb.py,v 1.48 2002-03-18 18:32:00 rochecompaan Exp $
+# $Id: roundupdb.py,v 1.52 2002-05-15 03:27:16 richard Exp $
__doc__ = """
Extending hyperdb with types specific to issue-tracking.
appended to the "messages" field of the specified issue.
"""
- def sendmessage(self, nodeid, msgid, change_note):
+ def nosymessage(self, nodeid, msgid, change_note):
"""Send a message to the members of an issue's nosy list.
The message is sent only to users on the nosy list who are not
"""
users = self.db.user
messages = self.db.msg
- files = self.db.file
# figure the recipient ids
sendto = []
sendto.append(nosyid)
recipients.append(nosyid)
- # no new recipients
- if not sendto:
- return
+ # we have new recipients
+ if sendto:
+ # map userids to addresses
+ sendto = [users.get(i, 'address') for i in sendto]
+
+ # update the message's recipients list
+ messages.set(msgid, recipients=recipients)
+
+ # send the message
+ self.send_message(nodeid, msgid, change_note, sendto)
+
+ # XXX backwards compatibility - don't remove
+ sendmessage = nosymessage
+
+ def send_message(self, nodeid, msgid, note, sendto):
+ '''Actually send the nominated message from this node to the sendto
+ recipients, with the note appended.
+ '''
+ users = self.db.user
+ messages = self.db.msg
+ files = self.db.file
# determine the messageid and inreplyto of the message
inreplyto = messages.get(msgid, 'inreplyto')
messageid = messages.get(msgid, 'messageid')
+
+ # make up a messageid if there isn't one (web edit)
if not messageid:
# this is an old message that didn't get a messageid, so
# create one
self.classname, nodeid, self.db.config.MAIL_DOMAIN)
messages.set(msgid, messageid=messageid)
- # update the message's recipients list
- messages.set(msgid, recipients=recipients)
-
# send an email to the people who missed out
- sendto = [users.get(i, 'address') for i in sendto]
cn = self.classname
title = self.get(nodeid, 'title') or '%s message copy'%cn
# figure author information
+ authid = messages.get(msgid, 'author')
authname = users.get(authid, 'realname')
if not authname:
authname = users.get(authid, 'username')
m.append(messages.get(msgid, 'content'))
# add the change note
- if change_note:
- m.append(change_note)
+ if note:
+ m.append(note)
# put in roundup's signature
if self.db.config.EMAIL_SIGNATURE_POSITION == 'bottom':
content = cStringIO.StringIO('\n'.join(m))
content_encoded = cStringIO.StringIO()
quopri.encode(content, content_encoded, 0)
- content_encoded.seek(0)
- content_encoded = content_encoded.read()
+ content_encoded = content_encoded.getvalue()
# get the files for this message
message_files = messages.get(msgid, 'files')
+ # make sure the To line is always the same (for testing mostly)
+ sendto.sort()
+
# create the message
message = cStringIO.StringIO()
writer = MimeWriter.MimeWriter(message)
# now try to send the message
if SENDMAILDEBUG:
open(SENDMAILDEBUG, 'w').write('FROM: %s\nTO: %s\n%s\n'%(
- self.db.config.ADMIN_EMAIL,', '.join(sendto),message.getvalue()))
+ self.db.config.ADMIN_EMAIL,
+ ', '.join(sendto),message.getvalue()))
else:
try:
# send the message as admin so bounces are sent there
key = link.labelprop(default_to_id=1)
if key:
value = [link.get(entry, key) for entry in value]
+ value.sort()
value = ', '.join(value)
m.append('%s: %s'%(propname, value))
m.insert(0, '----------')
#
# $Log: not supported by cvs2svn $
+# Revision 1.51 2002/04/08 03:46:42 richard
+# make it work
+#
+# Revision 1.50 2002/04/08 03:40:31 richard
+# . added a "detectors" directory for people to put their useful auditors and
+# reactors in. Note - the roundupdb.IssueClass.sendmessage method has been
+# split and renamed "nosymessage" specifically for things like the nosy
+# reactor, and "send_message" which just sends the message.
+#
+# The initial detector is one that we'll be using here at ekit - it bounces new
+# issue messages to a team address.
+#
+# Revision 1.49 2002/03/19 06:41:49 richard
+# Faster, easier, less mess ;)
+#
+# Revision 1.48 2002/03/18 18:32:00 rochecompaan
+# All messages sent to the nosy list are now encoded as quoted-printable.
+#
# Revision 1.47 2002/02/27 03:16:02 richard
# Fixed a couple of dodgy bits found by pychekcer.
#