Scarab commit: svn commit: r10156 - branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java

[email protected]
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2006-06-08 05:02:37-0700
New Revision: 10156

Modified:
   branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java

Log:
email sender will be exposed when only one contributor to email, otherwise Scarab administrator will be shown. behaviour enabled by scarab.email.replyto.sender=true

Modified: branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java?view=diff&rev=10156&p1=branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java&p2=branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java&r1=10155&r2=10156
==============================================================================
--- branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java	(original)
+++ branches/release/b21/src/java/org/tigris/scarab/notification/ScarabNewNotificationManager.java	2006-06-08 05:02:37-0700
@@ -621,17 +621,45 @@
         context.setSubjectTemplate("notification/IssueActivitySubject.vm");
         Set toUsers = new HashSet();
         toUsers.add(user);
+        
+        String[] fromUser    = getFromUser(issue, context);
         String[] replyToUser = issue.getModule().getSystemEmail();
         Email.sendEmail(
                 context,
                 issue.getModule(),
-                replyToUser,
+                fromUser,
                 replyToUser,
                 toUsers,
                 null,
                 "notification/IssueActivity.vm");
     }
 
+    private String[] getFromUser(Issue issue, EmailContext context) throws TorqueException
+    {
+        String[] replyToUser = null;
+    
+        Set creators = (Set)context.get("creators");
+        if (creators.size()==1)
+        {
+            // exactly one contributor to this E-Mail
+            boolean exposeSender = Turbine.getConfiguration()
+            .getBoolean("scarab.email.replyto.sender",false);
+
+            if(exposeSender)
+            {
+                ScarabUser creator = (ScarabUser)creators.toArray()[0];
+                replyToUser = new String[] { creator.getName(), creator.getEmail() };
+            }
+        }
+        
+        if(replyToUser == null)
+        {
+         replyToUser = issue.getModule().getSystemEmail();
+        }
+        
+        return replyToUser;
+    }
+
     private static Map typeDescriptions = new HashMap();
     
     /*
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.