Skip to content

Commit

Permalink
Setting for whether to allow occasional sending of pubkey.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smári McCarthy committed Oct 16, 2014
1 parent c5fa2a1 commit b49d036
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions mailpile/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
'gpg_clearsign': X(_('Inline PGP signatures or attached'),
bool, False),
'gpg_recipient': p(_('Encrypt local data to ...'), str, ''),
'gpg_email_key': (_('Attach public key to outgoing messages?'),
bool, True),
'openpgp_header': X(_('Advertise GPG preferences in a header?'),
['', 'sign', 'encrypt', 'signencrypt'],
'signencrypt'),
Expand Down
29 changes: 15 additions & 14 deletions mailpile/mailutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,20 +480,21 @@ def Create(cls, idx, mbox_id, mbx,
del att['MIME-Version']

# Determine if we want to attach a PGP public key due to timing:
addrs = ExtractEmails(norm(msg_to) + norm(msg_cc))
offset = timedelta(days=30)
dates = []
for addr in addrs:
vcard = idx.config.vcards.get(addr)
if vcard != None:
lastdate = vcard.gpgshared
if lastdate:
try:
dates.append(datetime.fromtimestamp(float(lastdate)))
except ValueError:
pass
if all([date+offset < datetime.now() for date in dates]):
msg["Attach-PGP-Pubkey"] = "Yes"
if idx.config.prefs.gpg_email_key:
addrs = ExtractEmails(norm(msg_to) + norm(msg_cc))
offset = timedelta(days=30)
dates = []
for addr in addrs:
vcard = idx.config.vcards.get(addr)
if vcard != None:
lastdate = vcard.gpgshared
if lastdate:
try:
dates.append(datetime.fromtimestamp(float(lastdate)))
except ValueError:
pass
if all([date+offset < datetime.now() for date in dates]):
msg["Attach-PGP-Pubkey"] = "Yes"

if save:
msg_key = mbx.add(MessageAsString(msg))
Expand Down

0 comments on commit b49d036

Please sign in to comment.