whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Allow Bcc: secretary to work
Date Thu, 14 May 2020 19:39:07 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 15df96c  Allow Bcc: secretary to work
15df96c is described below

commit 15df96c8cc6ae852e777f8deded50fe4b8a0c104
Author: Sebb <sebb@apache.org>
AuthorDate: Thu May 14 20:38:44 2020 +0100

    Allow Bcc: secretary to work
---
 www/secretary/workbench/models/message.rb          | 25 ++++++++++++----------
 www/secretary/workbench/views/actions/icla.json.rb |  6 +++++-
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/www/secretary/workbench/models/message.rb b/www/secretary/workbench/models/message.rb
index f2b8408..5896f08 100644
--- a/www/secretary/workbench/models/message.rb
+++ b/www/secretary/workbench/models/message.rb
@@ -241,6 +241,16 @@ class Message
     cc = []
     bcc = []
 
+    # process 'bcc' addresses on method call
+    # Do this first so can suppress such addresses in To: and Cc: fields
+    if fields[:bcc]
+      Array(fields[:bcc]).compact.each do |addr|
+        addr = Message.liberal_email_parser(addr) if addr.is_a? String
+        next if bcc.any? {|a| a.address == addr.address}
+        bcc << addr
+      end
+    end
+
     # process 'to' addresses on method call
     if fields[:to]
       Array(fields[:to]).compact.each do |addr|
@@ -255,6 +265,7 @@ class Message
       next if to.any? {|a| a.address == addr.address}
       if fields[:to]
         next if cc.any? {|a| a.address == addr.address}
+        next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc
         cc << addr
       else
         to << addr
@@ -266,6 +277,7 @@ class Message
       self.to.addrs.each do |addr|
         next if to.any? {|a| a.address == addr.address}
         next if cc.any? {|a| a.address == addr.address}
+        next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc
         cc << addr
       end
     end
@@ -276,6 +288,7 @@ class Message
         addr = Message.liberal_email_parser(addr) if addr.is_a? String
         next if to.any? {|a| a.address == addr.address}
         next if cc.any? {|a| a.address == addr.address}
+        next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc
         cc << addr
       end
     end
@@ -286,21 +299,11 @@ class Message
         addr = Message.liberal_email_parser(addr) if addr.is_a? String
         next if to.any? {|a| a.address == addr.address}
         next if cc.any? {|a| a.address == addr.address}
+        next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc
         cc << addr
       end
     end
 
-    # process 'bcc' addresses on method call
-    if fields[:bcc]
-      Array(fields[:bcc]).compact.each do |addr|
-        addr = Message.liberal_email_parser(addr) if addr.is_a? String
-        next if to.any? {|a| a.address == addr.address}
-        next if cc.any? {|a| a.address == addr.address}
-        next if bcc.any? {|a| a.address == addr.address}
-        bcc << addr
-      end
-    end
-
     # reformat and untaint email addresses
     mail[:to] = to.map {|addr| addr.format.dup.untaint}
     mail[:cc] = cc.map {|addr| addr.format.dup.untaint} unless cc.empty?
diff --git a/www/secretary/workbench/views/actions/icla.json.rb b/www/secretary/workbench/views/actions/icla.json.rb
index bccd944..b5ba9ef 100644
--- a/www/secretary/workbench/views/actions/icla.json.rb
+++ b/www/secretary/workbench/views/actions/icla.json.rb
@@ -180,7 +180,11 @@ task "email #@email" do
 
   # echo email
   form do
-    _message mail.to_s
+    if use_Bcc # Show Bcc
+      _message "Bcc: #{mail[:bcc].decoded}\r\n#{mail.to_s}"
+    else
+      _message mail.to_s
+    end
   end
 
   # deliver mail


Mime
View raw message