summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-08-10 15:38:58 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-08-11 08:25:51 -0700
commit35f7c26c9187e06e8cbeb0a03dd0721174b7ead2 (patch)
tree9a50a062e7e447f467969a4e2d919d38242aac28 /alot
parentc3a0ec29c55a6ecade79bfd11f44965e0e9a1640 (diff)
commands: Don't try to sign_by_default without a gpg key
Currently it's possible to set sign_by_default without setting a default key. This is obviously not a good plan for all sorts of reasons. This fixes the two failing tests from the last commit.
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/globals.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 79b7e5f6..dd04d529 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -857,8 +857,14 @@ class ComposeCommand(Command):
# Figure out whether we should GPG sign messages by default
# and look up key if so
- self.envelope.sign = account.sign_by_default
- self.envelope.sign_key = account.gpg_key
+ if account.sign_by_default:
+ if account.gpg_key:
+ self.envelope.sign = account.sign_by_default
+ self.envelope.sign_key = account.gpg_key
+ else:
+ msg = 'Cannot find gpg key for account {}'.format(account.address)
+ logging.warn(msg)
+ ui.notify(msg, priority='error')
# get missing To header
if 'To' not in self.envelope.headers: