diff options
author | vrs <none> | 2018-12-08 22:20:05 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-12-10 10:25:49 +0000 |
commit | b981bfe0c61d9aa55652b4b0a01b846aaa9c993a (patch) | |
tree | b16298ac338ef19758af553b845ddc05b6124fc1 /alot/commands/envelope.py | |
parent | fdac378674a3e90413fcfba3dd2c9cc0debbb9cc (diff) |
attach accounts to envelopes
simplifies a few tests, fixes #1177
Diffstat (limited to 'alot/commands/envelope.py')
-rw-r--r-- | alot/commands/envelope.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index b300125c..2aa15475 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -114,12 +114,14 @@ class SaveCommand(Command): envelope = ui.current_buffer.envelope # determine account to use - try: - account = settings.get_account_by_address( - envelope['From'], return_default=True) - except NoMatchingAccount: - ui.notify('no accounts set.', priority='error') - return + if envelope.account is None: + try: + envelope.account = settings.account_matching_address( + envelope['From'], return_default=True) + except NoMatchingAccount: + ui.notify('no accounts set.', priority='error') + return + account = envelope.account if account.draft_box is None: msg = 'abort: Account for {} has no draft_box' @@ -271,6 +273,7 @@ class SendCommand(Command): await account.send_mail(self.mail) except SendingMailFailed as e: if self.envelope is not None: + self.envelope.account = account self.envelope.sending = False ui.clear_notify([clearme]) logging.error(traceback.format_exc()) @@ -538,13 +541,16 @@ class SignCommand(Command): ui.notify(str(e), priority='error') return else: - try: - acc = settings.get_account_by_address(envelope['From']) - except NoMatchingAccount: - envelope.sign = False - ui.notify('Unable to find a matching account', - priority='error') - return + if envelope.account is None: + try: + envelope.account = settings.get_account_by_address( + envelope['From']) + except NoMatchingAccount: + envelope.sign = False + ui.notify('Unable to find a matching account', + priority='error') + return + acc = envelope.account if not acc.gpg_key: envelope.sign = False msg = 'Account for {} has no gpg key' |