gpgme_ctx = gpgme.Context()
gpgme_ctx.armor = True
- add_gpg_keys(email_text, gpgme_ctx)
-
- plaintext, keys = email_decode_flatten(email_text, gpgme_ctx)
+ plaintext, keys = email_decode_flatten(email_text, gpgme_ctx, False)
encrypt_to_key = choose_reply_encryption_key(keys)
reply_message = generate_reply(plaintext, email_from, \
print(reply_message)
-def email_decode_flatten (email_text, gpgme_ctx):
+def email_decode_flatten (email_text, gpgme_ctx, from_decryption):
body = ""
keys = []
keys += add_gpg_keys(payload, gpgme_ctx)
elif content_type == "text/plain":
- body += payload + "\n"
+ if from_decryption == True:
+ body += payload + "\n"
+
+ else:
+ plaintext, more_keys = decrypt_text(payload, gpgme_ctx)
+
+ body += plaintext
+ keys += more_keys
- else:
- body += payload + "\n"
+ keys += add_gpg_keys(payload, gpgme_ctx)
return body, keys
keys += [gpgme_ctx.get_key(sig.fpr)]
# recursive for nested layers of mime and/or gpg
- plaintext, more_keys = email_decode_flatten(plaintext, gpgme_ctx)
+ plaintext, more_keys = email_decode_flatten(plaintext, gpgme_ctx, True)
body += plaintext
keys += more_keys