diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2016-03-12 09:16:04 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2016-03-24 21:01:43 +0000 |
commit | c6b5e7ae3c70531b01e9cbb5f5c4af1b020cae8e (patch) | |
tree | c5295d89581fc609fbdf91ba693c5a5509be0e7a /alot | |
parent | 2fbef26748c1199b6a1d0024ddf1916ab7db0be8 (diff) |
Fix top level check for encrypt_by_default.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/globals.py | 23 |
1 files changed, 17 insertions, 6 deletions
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 |