summaryrefslogtreecommitdiff
path: root/alot/commands/utils.py
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-09-25 20:22:30 +0200
committerRuben Pollan <meskio@sindominio.net>2017-09-26 08:49:16 +0200
commit7cd3cff8d858e411f8d84361d5a4bc6133c86d0e (patch)
tree61a9af9ac906185aa61581f0919c830dc87730d7 /alot/commands/utils.py
parent5904b86d09edb888c80f8f8ba7f1b2e18baf456a (diff)
commands/util: encrypt to self
Add account configuration variable 'encrypt_to_self' that if true when encrypting a message it will also be encrypted with the key defined for this account. Fixes #1140
Diffstat (limited to 'alot/commands/utils.py')
-rw-r--r--alot/commands/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/alot/commands/utils.py b/alot/commands/utils.py
index 1bf64cbb..7e4e0307 100644
--- a/alot/commands/utils.py
+++ b/alot/commands/utils.py
@@ -9,6 +9,8 @@ import logging
from twisted.internet.defer import inlineCallbacks, returnValue
from ..errors import GPGProblem, GPGCode
+from ..settings.const import settings
+from ..settings.errors import NoMatchingAccount
from .. import crypto
@@ -46,6 +48,19 @@ def set_encrypt(ui, envelope, block_error=False, signed_only=False):
if keys:
envelope.encrypt_keys.update(keys)
envelope.encrypt = True
+
+ if 'From' in envelope.headers:
+ try:
+ acc = settings.get_account_by_address(envelope['From'])
+ if acc.encrypt_to_self:
+ if acc.gpg_key:
+ logging.debug('encrypt to self: %s', acc.gpg_key.fpr)
+ envelope.encrypt_keys[acc.gpg_key.fpr] = acc.gpg_key
+ else:
+ logging.debug('encrypt to self: no gpg_key in account')
+ except NoMatchingAccount:
+ logging.debug('encrypt to self: no account found')
+
else:
envelope.encrypt = False