whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit aa67571: override octet-stream for attachments based on ext
Date Tue, 19 Jan 2016 19:04:24 GMT
Commit aa675713d13aae3368de1cf74a0ace699c056e42:
    override octet-stream for attachments based on ext


Branch: refs/heads/master
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
www/secmail/models/attachment.rb                             | +++++++++++++ -
------------------------------------------------------------
14 changes: 13 additions, 1 deletions.
------------------------------------------------------------


diff --git a/www/secmail/models/attachment.rb b/www/secmail/models/attachment.rb
index 28f13e8..ce2733d 100644
--- a/www/secmail/models/attachment.rb
+++ b/www/secmail/models/attachment.rb
@@ -13,7 +13,19 @@ def name
   end
 
   def content_type
-    headers[:mime] || @part.content_type
+    type = headers[:mime] || @part.content_type
+
+    if type == 'application/octet-stream'
+      type = 'text/plain' if name.end_with? '.sig'
+      type = 'text/plain' if name.end_with? '.asc'
+      type = 'application/pdf' if name.end_with? '.pdf'
+      type = 'image/gif' if name.end_with? '.gif'
+      type = 'image/jpeg' if name.end_with? '.jpg'
+      type = 'image/jpeg' if name.end_with? '.jpeg'
+      type = 'image/png' if name.end_with? '.png'
+    end
+
+    type
   end
 
   def body

Mime
View raw message