Save draft state in message header for now

Apparently, storing the draft state header in the encrypted payload
introduces difficulties in Enigmail due to restrictions from
Thunderbird. To stay compatible, this commit keeps the draft state in
the outer header for now, but we should move it into the encrypted
payload if the issue with Thunderbird is somehow resolved.

see: https://github.com/autocrypt/autocrypt/pull/376#issuecomment-384293480
This commit is contained in:
Vincent Breitmoser 2018-04-27 19:40:25 +02:00
parent 39a732d0c3
commit d0e588fb9f
3 changed files with 6 additions and 12 deletions

View file

@ -168,11 +168,13 @@ public class PgpMessageBuilder extends MessageBuilder {
boolean payloadSupportsMimeHeaders = !isPgpInlineMode;
if (payloadSupportsMimeHeaders) {
moveDraftStateIntoEncryptedPayload();
if (cryptoStatus.isEncryptSubject()) {
moveSubjectIntoEncryptedPayload();
}
maybeAddGossipHeadersToBodyPart();
// unfortuntately, we can't store the Autocrypt-Draft-State header in the payload
// see https://github.com/autocrypt/autocrypt/pull/376#issuecomment-384293480
}
}
@ -219,14 +221,6 @@ public class PgpMessageBuilder extends MessageBuilder {
}
}
private void moveDraftStateIntoEncryptedPayload() {
String[] autocryptDraftState = currentProcessedMimeMessage.getHeader(AutocryptDraftStateHeader.AUTOCRYPT_DRAFT_STATE_HEADER);
if (autocryptDraftState.length == 1) {
messageContentBodyPart.setHeader(AutocryptDraftStateHeader.AUTOCRYPT_DRAFT_STATE_HEADER, autocryptDraftState[0]);
currentProcessedMimeMessage.removeHeader(AutocryptDraftStateHeader.AUTOCRYPT_DRAFT_STATE_HEADER);
}
}
private void maybeAddGossipHeadersToBodyPart() {
if (!cryptoStatus.isEncryptionEnabled()) {
return;

View file

@ -1306,7 +1306,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
draftId = MessagingController.getInstance(getApplication()).getId(message);
subjectView.setText(messageViewInfo.subject);
recipientPresenter.initFromDraftMessage(message, messageViewInfo.rootPart);
recipientPresenter.initFromDraftMessage(message);
// Read In-Reply-To header from draft
final String[] inReplyTo = message.getHeader("In-Reply-To");

View file

@ -225,10 +225,10 @@ public class RecipientPresenter {
outState.putBoolean(STATE_KEY_CRYPTO_ENABLE_PGP_INLINE, cryptoEnablePgpInline);
}
public void initFromDraftMessage(Message message, Part rootPart) {
public void initFromDraftMessage(Message message) {
initRecipientsFromDraftMessage(message);
String[] draftStateHeader = rootPart.getHeader(AutocryptDraftStateHeader.AUTOCRYPT_DRAFT_STATE_HEADER);
String[] draftStateHeader = message.getHeader(AutocryptDraftStateHeader.AUTOCRYPT_DRAFT_STATE_HEADER);
if (draftStateHeader.length == 1) {
initEncryptionStateFromDraftStateHeader(draftStateHeader[0]);
} else {