[gnome-keysign: 6/10] util: made sign_keydata_and_send yield the plaintext



commit bfc13a373ad75501066124065299d5588c52aef5
Author: Tobias Mueller <muelli cryptobitch de>
Date:   Fri May 10 10:50:51 2019 +0200

    util: made sign_keydata_and_send yield the plaintext
    
    The calling sites should have been updated to handle this tuple now.

 keysign/receive.py | 7 +++++--
 keysign/util.py    | 7 ++++---
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/keysign/receive.py b/keysign/receive.py
index 98cb5ee..59442a6 100755
--- a/keysign/receive.py
+++ b/keysign/receive.py
@@ -201,8 +201,11 @@ class ReceiveApp:
         self.log.debug ("Sign key confirmed! %r", key)
         # We need to prevent tmpfiles from going out of
         # scope too early so that they don't get deleted
-        self.tmpfiles = list(
-            sign_keydata_and_send(keydata))
+        tmpfiles_plaintext = list(sign_keydata_and_send(keydata))
+        self.log.debug("sign keydata result: %r", tmpfiles_plaintext)
+        # This is unzipping the list of tuples, e.g. [(1,2), (3,4)] becomes [(1,3), (2,4)]
+        self.tmpfiles, plaintexts = zip(*tmpfiles_plaintext)
+
 
         # After the user has signed, we switch back to the scanner,
         # because currently, there is not much to do on the
diff --git a/keysign/util.py b/keysign/util.py
index bdfc85c..9e20a75 100755
--- a/keysign/util.py
+++ b/keysign/util.py
@@ -243,8 +243,9 @@ def sign_keydata_and_send(keydata, error_cb=None):
     For the resulting signatures, emails are created and
     sent via send_email.
     
-    Return value:  NamedTemporaryFiles used for saving the signatures.
-    If you let them go out of scope they should get deleted.
+    Return value:  A tuple of a
+    NamedTemporaryFiles used for saving the signatures and the plaintext which got encrypted.
+    If you let the TemporaryFiles go out of scope they should get deleted.
     But don't delete too early as the MUA needs to pick them up.
     """
     log = logging.getLogger(__name__ + ':sign_keydata')
@@ -291,7 +292,7 @@ def sign_keydata_and_send(keydata, error_cb=None):
         subject = Template(SUBJECT).safe_substitute(ctx)
         body = Template(body).safe_substitute(ctx)
         send_email(uid.email, subject, body, [filename])
-        yield tmpfile
+        yield tmpfile, plaintext
 
 
 def format_fingerprint(fpr):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]