From c6b5e7ae3c70531b01e9cbb5f5c4af1b020cae8e Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Sat, 12 Mar 2016 09:16:04 +0100 Subject: Fix top level check for encrypt_by_default. --- alot/commands/globals.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'alot') diff --git a/alot/commands/globals.py b/alot/commands/globals.py index e812fe68..f5ffe8d7 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -851,10 +851,21 @@ class ComposeCommand(Command): logging.debug('attaching: ' + a) # set encryption if needed - if self.encrypt or account.encrypt_by_default is True: + if self.encrypt or account.encrypt_by_default == u"all" or \ + account.encrypt_by_default == u"True": + logging.debug("Trying to encrypt message because encrypt={} and " + "encrypt_by_default={}".format( + self.encrypt, account.encrypt_by_default)) yield self._set_encrypt(ui, self.envelope) - elif account.encrypt_by_default == "Valid": + elif account.encrypt_by_default == u"trusted": + logging.debug("Trying to encrypt message because " + "account.encrypt_by_default={}".format( + account.encrypt_by_default)) yield self._set_encrypt(ui, self.envelope, trusted_only=True) + else: + logging.debug( + "No encryption by default, encrypt_by_default={}".format( + account.encrypt_by_default)) cmd = commands.envelope.EditCommand(envelope=self.envelope, spawn=self.force_spawn, @@ -862,16 +873,16 @@ class ComposeCommand(Command): ui.apply_command(cmd) @inlineCallbacks - def _set_encrypt(self, ui, envelope, signed_only=False): + def _set_encrypt(self, ui, envelope, trusted_only=False): """Find and set the encryption keys in an envolope. :param ui: the main user interface object :type ui: alot.ui.UI :param envolope: the envolope buffer object :type envolope: alot.buffers.EnvelopeBuffer - :param signed_only: only add keys to the list of encryption + :param trusted_only: only add keys to the list of encryption keys whose uid is signed (trusted to belong to the key) - :type signed_only: bool + :type trusted_only: bool """ encrypt_keys = [] @@ -885,7 +896,7 @@ class ComposeCommand(Command): logging.debug("encryption keys: " + str(encrypt_keys)) keys = yield get_keys(ui, encrypt_keys, block_error=self.encrypt, - signed_only=signed_only) + signed_only=trusted_only) if keys: envelope.encrypt_keys.update(keys) envelope.encrypt = True -- cgit v1.2.3