Commit aa675713d13aae3368de1cf74a0ace699c056e42:
override octet-stream for attachments based on ext
Branch: refs/heads/master
Author: Sam Ruby <[email protected]>
Committer: Sam Ruby <[email protected]>
Pusher: rubys <[email protected]>
------------------------------------------------------------
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