diff --git a/internal/smtp/preferences.go b/internal/smtp/preferences.go index a02c59c2..28dead1f 100644 --- a/internal/smtp/preferences.go +++ b/internal/smtp/preferences.go @@ -95,11 +95,13 @@ func (b *sendPreferencesBuilder) shouldEncrypt() bool { return false } -func (b *sendPreferencesBuilder) withSign(v bool) { +func (b *sendPreferencesBuilder) withSign() { + v := true b.sign = &v } -func (b *sendPreferencesBuilder) withSignDefault(v bool) { +func (b *sendPreferencesBuilder) withSignDefault() { + v := true if b.sign == nil { b.sign = &v } @@ -256,7 +258,7 @@ func (b *sendPreferencesBuilder) setInternalPGPSettings( // We always encrypt and sign internal mail. b.withEncrypt(true) - b.withSign(true) + b.withSign() // We use a custom scheme for internal messages. b.withScheme(pmInternal) @@ -367,7 +369,7 @@ func (b *sendPreferencesBuilder) setExternalPGPSettingsWithWKDKeys( // We always encrypt and sign external mail if WKD keys are present. b.withEncrypt(true) - b.withSign(true) + b.withSign() // If the contact has a specific Scheme preference, we set it (otherwise we // leave it unset to allow it to be filled in with the default value later). @@ -402,7 +404,7 @@ func (b *sendPreferencesBuilder) setExternalPGPSettingsWithoutWKDKeys( // Sign must be enabled whenever encrypt is. if vCardData.Sign || vCardData.Encrypt { - b.withSign(true) + b.withSign() } // If the contact has a specific Scheme preference, we set it (otherwise we @@ -468,10 +470,12 @@ func (b *sendPreferencesBuilder) setEncryptionPreferences(mailSettings pmapi.Mai // mail setting "Sign External messages". Otherwise we keep the defined value // unless it conflicts with the encrypt flag (we do not allow to send // encrypted but not signed). - b.withSignDefault(mailSettings.Sign > 0) + if mailSettings.Sign > 0 { + b.withSignDefault() + } if b.shouldEncrypt() { - b.withSign(true) + b.withSign() } // If undefined, default to the user mail setting "Default PGP scheme". diff --git a/internal/smtp/preferences_test.go b/internal/smtp/preferences_test.go index d08f3400..f36133d4 100644 --- a/internal/smtp/preferences_test.go +++ b/internal/smtp/preferences_test.go @@ -56,7 +56,7 @@ func TestPreferencesBuilder(t *testing.T) { wantEncrypt: true, wantSign: true, wantScheme: pmapi.InternalPackage, - wantMIMEType: "multipart/mixed", + wantMIMEType: "text/html", wantPublicKey: testPublicKey, }, @@ -71,7 +71,7 @@ func TestPreferencesBuilder(t *testing.T) { wantEncrypt: true, wantSign: true, wantScheme: pmapi.InternalPackage, - wantMIMEType: "multipart/mixed", + wantMIMEType: "text/plain", wantPublicKey: testPublicKey, }, @@ -86,7 +86,7 @@ func TestPreferencesBuilder(t *testing.T) { wantEncrypt: true, wantSign: true, wantScheme: pmapi.InternalPackage, - wantMIMEType: "multipart/mixed", + wantMIMEType: "text/html", wantPublicKey: testPublicKey, }, @@ -102,7 +102,7 @@ func TestPreferencesBuilder(t *testing.T) { wantEncrypt: true, wantSign: true, wantScheme: pmapi.InternalPackage, - wantMIMEType: "multipart/mixed", + wantMIMEType: "text/html", wantPublicKey: testPublicKey, },