]> git.cworth.org Git - sup/commitdiff
bugfix: crypto return values when no gpg binary detected
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 4 Sep 2009 14:29:13 +0000 (10:29 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 4 Sep 2009 14:29:13 +0000 (10:29 -0400)
Tweak the return values of CryptoManager#decrypt so that the notice widget is
the first thing returned regardless. Makes the code cleaner.

lib/sup/crypto.rb
lib/sup/message.rb

index 7f044b99428d0beb80bfb22fa1f4cda6bc127011..772b8b696c4f4f41682fe2e51f4656bc66603254 100644 (file)
@@ -129,10 +129,9 @@ class CryptoManager
       end
 
       notice = Chunk::CryptoNotice.new :valid, "This message has been decrypted for display"
-      [RMail::Parser.read(decrypted_payload), sig, notice]
+      [notice, sig, RMail::Parser.read(decrypted_payload)]
     else
-      notice = Chunk::CryptoNotice.new :invalid, "This message could not be decrypted", output.split("\n")
-      [nil, nil, notice]
+      Chunk::CryptoNotice.new :invalid, "This message could not be decrypted", output.split("\n")
     end
   end
 
index ed27d3dccfba056410bd90225604479f8e788797..426eb80019c2c7b2015159ceb3413a2d65e1f1ef 100644 (file)
@@ -382,9 +382,13 @@ private
       return
     end
 
-    decryptedm, sig, notice = CryptoManager.decrypt payload
-    children = message_to_chunks(decryptedm, true) if decryptedm
-    [notice, sig, children].flatten.compact
+    notice, sig, decryptedm = CryptoManager.decrypt payload
+    if decryptedm # managed to decrypt
+      children = message_to_chunks(decryptedm, true)
+      [notice, sig, children]
+    else
+      [notice]
+    end
   end
 
   ## takes a RMail::Message, breaks it into Chunk:: classes.