summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/mail
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2017-04-21 17:20:03 -0300
committerRuben Pollan <meskio@sindominio.net>2017-12-03 20:43:37 +0100
commitfbdb541bfc0fcbf2d9c92c785f0d8ff1fe98f68a (patch)
tree147b54d3263b8354dfafc1c798558c71920b59aa /src/leap/bitmask/mail
parent85c0e9b95dfc3d7134e47aac7e7e485270b42b96 (diff)
[feat] send public key as attachment on every email
Previously, we were sending the key attached as long as the contact hasn't replied back. But with new key replace scenarios, we need to updated the contact keyring with the new key. We can implement autocrypt or similar in the future, but for now, let's send the key attached on every email.
Diffstat (limited to 'src/leap/bitmask/mail')
-rw-r--r--src/leap/bitmask/mail/outgoing/service.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/leap/bitmask/mail/outgoing/service.py b/src/leap/bitmask/mail/outgoing/service.py
index 18d266ef..4f39691b 100644
--- a/src/leap/bitmask/mail/outgoing/service.py
+++ b/src/leap/bitmask/mail/outgoing/service.py
@@ -315,23 +315,14 @@ class OutgoingMail(object):
emit_async(catalog.SMTP_START_ENCRYPT_AND_SIGN,
self._from_address,
"%s,%s" % (self._from_address, to_address))
- d = self._maybe_attach_key(origmsg, from_address, to_address)
+ d = self._attach_key(origmsg, from_address)
d.addCallback(maybe_encrypt_and_sign)
return d
- def _maybe_attach_key(self, origmsg, from_address, to_address):
+ def _attach_key(self, origmsg, from_address):
filename = "%s-email-key.asc" % (from_address,)
- def attach_if_address_hasnt_encrypted(to_key):
- # if the sign_used flag is true that means that we got an encrypted
- # email from this address, because we conly check signatures on
- # encrypted emails. In this case we don't attach.
- # XXX: this might not be true some time in the future
- if to_key.sign_used:
- return origmsg
- return get_key_and_attach(None)
-
- def get_key_and_attach(_):
+ def get_key_and_attach():
d = self._keymanager.get_key(from_address, fetch_remote=False)
d.addCallback(attach_key)
return d
@@ -352,8 +343,9 @@ class OutgoingMail(object):
msg.attach(keymsg)
return msg
- d = self._keymanager.get_key(to_address, fetch_remote=False)
- d.addCallbacks(attach_if_address_hasnt_encrypted, get_key_and_attach)
+ self.log.info("Will send %s public key as an attachment."
+ % (from_address))
+ d = get_key_and_attach()
d.addErrback(lambda _: origmsg)
return d