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: skip messages that only have signature attachments
Date Sun, 02 Oct 2016 15:36:57 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  676fc04   skip messages that only have signature attachments
676fc04 is described below

commit 676fc043cf2f8c7bda79fff67b2cbce832016dea
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Sun Oct 2 11:36:21 2016 -0400

    skip messages that only have signature attachments
---
 www/secmail/models/mailbox.rb   |  2 +-
 www/secmail/models/message.rb   | 10 ++++++++--
 www/secmail/views/index.json.rb |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/www/secmail/models/mailbox.rb b/www/secmail/models/mailbox.rb
index 8873651..4a449b5 100644
--- a/www/secmail/models/mailbox.rb
+++ b/www/secmail/models/mailbox.rb
@@ -156,7 +156,7 @@ class Mailbox
   def client_headers
     # fetch a list of headers for all messages in the maibox with attachments
     headers = self.headers.to_a.select do |id, message|
-      message[:attachments]
+      not Message.attachments(message).empty?
     end
 
     # extract relevant fields from the headers
diff --git a/www/secmail/models/message.rb b/www/secmail/models/message.rb
index 58a6f3d..56b7ae0 100644
--- a/www/secmail/models/message.rb
+++ b/www/secmail/models/message.rb
@@ -97,13 +97,19 @@ class Message
     mail.text_part
   end
 
-  def attachments
-    @headers[:attachments].
+  def self.attachments(headers)
+    attachments = headers[:attachments]
+    return [] unless attachments
+    attachments.
       reject {|attachment| SIG_MIMES.include? attachment[:mime]}.
       map {|attachment| attachment[:name]}.
       select {|name| name != 'signature.asc'}
   end
 
+  def attachments
+    Message.attachments(@headers)
+  end
+
   #
   # attachment operations: update, replace, delete
   #
diff --git a/www/secmail/views/index.json.rb b/www/secmail/views/index.json.rb
index 54c1d06..c685b42 100644
--- a/www/secmail/views/index.json.rb
+++ b/www/secmail/views/index.json.rb
@@ -9,7 +9,7 @@ if index
   if index > 0
     prevmbox = available[index-1].untaint
     prevmbox = nil unless YAML.load_file(prevmbox).any? do |key, mail| 
-      mail[:status] != :deleted and mail[:attachments]
+      mail[:status] != :deleted and not Message.attachments(mail).empty?
     end
   end
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message