summaryrefslogtreecommitdiff
path: root/alot/commands/globals.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-07-27 10:34:18 -0700
committerPatrick Totzke <patricktotzke@gmail.com>2019-05-11 17:37:57 +0100
commite4933f0eccc5d4afce26a9a6821e3edca562a894 (patch)
tree102928dd0678b7071a49c8f39e4a6c93b8d5dcad /alot/commands/globals.py
parentacdecb9010df7600cff86da1bfbf579bc25f71cf (diff)
commands/globals: split gpg signing code into a helper
Diffstat (limited to 'alot/commands/globals.py')
-rw-r--r--alot/commands/globals.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index f2c7407c..7c167caa 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -910,6 +910,17 @@ class ComposeCommand(Command):
else:
self.envelope = Envelope()
+ def _set_gpg_sign(self, ui, account):
+ 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 {}'
+ msg = msg.format(account.address)
+ logging.warning(msg)
+ ui.notify(msg, priority='error')
+
async def __apply(self, ui):
self._set_envelope()
if self.template is not None:
@@ -941,15 +952,7 @@ class ComposeCommand(Command):
# Figure out whether we should GPG sign messages by default
# and look up key if so
- 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 {}'
- msg = msg.format(account.address)
- logging.warning(msg)
- ui.notify(msg, priority='error')
+ self._set_gpg_sign(ui, account)
# get missing To header
if 'To' not in self.envelope.headers: