Code

attempt to fix the template finding
[roundup.git] / roundup / roundupdb.py
index 0bf115da95f8a627c9103b08a567c5777a164464..e5967431488b52fcf2c228fcc24af935b2fce83f 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: roundupdb.py,v 1.82 2003-02-24 05:16:57 richard Exp $
+# $Id: roundupdb.py,v 1.86 2003-04-27 02:24:37 richard Exp $
 
 __doc__ = """
 Extending hyperdb with types specific to issue-tracking.
@@ -43,7 +43,8 @@ except ImportError :
             return '%s%s%s <%s>' % (quotes, name, quotes, address)
         return address
 
-import hyperdb
+from roundup import hyperdb
+from roundup.mailgw import openSMTPConnection
 
 # set to indicate to roundup not to actually _send_ email
 # this var must contain a file to write the mail to
@@ -132,23 +133,27 @@ class IssueClass:
         # anonymous
         if (users.get(authid, 'username') != 'anonymous' and
                 not r.has_key(authid)):
-            if self.db.config.MESSAGES_TO_AUTHOR == 'yes':
-                # always CC the author of the message
-                sendto.append(authid)
-                recipients.append(authid)
-            elif self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues:
-                # only CC the author if the issue is new
-                sendto.append(authid)
-                recipients.append(authid)
+            if (self.db.config.MESSAGES_TO_AUTHOR == 'yes' or
+                (self.db.config.MESSAGES_TO_AUTHOR == 'new' and not oldvalues)):
+                # make sure they have an address
+                add = users.get(authid, 'address')
+                if add:
+                    # send it to them
+                    sendto.append(add)
+                    recipients.append(authid)
+
         r[authid] = 1
 
         # now deal with cc people.
         for cc_userid in cc :
             if r.has_key(cc_userid):
                 continue
-            # send it to them
-            sendto.append(cc_userid)
-            recipients.append(cc_userid)
+            # make sure they have an address
+            add = users.get(cc_userid, 'address')
+            if add:
+                # send it to them
+                sendto.append(add)
+                recipients.append(cc_userid)
 
         # now figure the nosy people who weren't recipients
         nosy = self.get(nodeid, whichnosy)
@@ -160,9 +165,12 @@ class IssueClass:
                 continue
             # make sure they haven't seen the message already
             if not r.has_key(nosyid):
-                # send it to them
-                sendto.append(nosyid)
-                recipients.append(nosyid)
+                # make sure they have an address
+                add = users.get(nosyid, 'address')
+                if add:
+                    # send it to them
+                    sendto.append(add)
+                    recipients.append(nosyid)
 
         # generate a change note
         if oldvalues:
@@ -172,9 +180,6 @@ class IssueClass:
 
         # 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)
 
@@ -333,7 +338,7 @@ class IssueClass:
             try:
                 # send the message as admin so bounces are sent there
                 # instead of to roundup
-                smtp = smtplib.SMTP(self.db.config.MAILHOST)
+                smtp = openSMTPConnection(self.db.config)
                 smtp.sendmail(self.db.config.ADMIN_EMAIL, sendto,
                     message.getvalue())
             except socket.error, value:
@@ -361,8 +366,8 @@ class IssueClass:
         email = straddr((self.db.config.TRACKER_NAME,
             self.db.config.TRACKER_EMAIL))
 
-        line = '_' * max(len(web), len(email))
-        return '%s\n%s\n%s\n%s'%(line, email, web, line)
+        line = '_' * max(len(web)+2, len(email))
+        return '%s\n%s\n<%s>\n%s'%(line, email, web, line)
 
 
     def generateCreateNote(self, nodeid):