Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0e588fb authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

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
parent 39a732d0
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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");
+2 −2
Original line number Diff line number Diff line
@@ -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 {