whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: Defensive programming, handle the lack of 'to' and 'cc' fields.
Date Thu, 09 Aug 2018 00:54:53 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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 0bdad2f  Defensive programming, handle the lack of 'to' and 'cc' fields.
0bdad2f is described below

commit 0bdad2f6fd031fde0e15ad324affba2670b5b7f7
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Wed Aug 8 20:54:27 2018 -0400

    Defensive programming, handle the lack of 'to' and 'cc' fields.
---
 www/secretary/workbench/models/message.rb | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/www/secretary/workbench/models/message.rb b/www/secretary/workbench/models/message.rb
index aed4a41..4fd5fe9 100644
--- a/www/secretary/workbench/models/message.rb
+++ b/www/secretary/workbench/models/message.rb
@@ -260,18 +260,22 @@ class Message
     end
 
     # process 'to' addresses from original email
-    self.to.addrs.each do |addr|
-      next if to.any? {|a| a.address == addr.address}
-      next if cc.any? {|a| a.address == addr.address}
-      cc << addr
+    if self.to
+      self.to.addrs.each do |addr|
+        next if to.any? {|a| a.address == addr.address}
+        next if cc.any? {|a| a.address == addr.address}
+        cc << addr
+      end
     end
 
     # process 'cc' addresses from original email
-    self.cc.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}
-      cc << addr
+    if self.cc
+      self.cc.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}
+        cc << addr
+      end
     end
 
     # process 'cc' addresses on method call


Mime
View raw message