Commit 64b9b6cf authored by ng's avatar ng

fix #343 - improve message in pseudo header on fallback resend

Make it more clear what happens when resending an encrypted email
fails (due to missing or too many matching keys), but falling
back to unencrypted resend is allowed.
parent 711916e8
......@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Fix running Schleuder with ruby 2.7.
* Ensure that GnuPG never asks for a passphrase, even if it wants one. (#448)
* Be more precise about how many keys are in the keyring and how many are usable, when resending (#429)
* Make it more clear what happens when resending an encrypted email fails (due to missing or too many matching keys), but falling back to unencrypted resend is allowed. (#343)
## [3.4.1] / 2019-09-16
......
......@@ -125,14 +125,14 @@ module Schleuder
if encrypted_only
# Don't add the email to the result to exclude it from the
# recipients.
add_keys_error(mail, email, usable_keys.size, keys.size)
add_resend_msg(mail, email, :error, 'not_resent_no_keys', usable_keys.size, keys.size)
else
hash[email] = ''
end
else
# Always report this situation, regardless of sending or not. It's
# bad and should be fixed.
add_keys_error(mail, email, usable_keys.size, keys.size)
add_resend_msg(mail, email, :notice, 'not_resent_encrypted_no_keys', usable_keys.size, keys.size)
if ! encrypted_only
hash[email] = ''
end
......@@ -152,8 +152,8 @@ module Schleuder
gpg_opts
end
def self.add_keys_error(mail, email, usable_keys_size, all_keys_size)
mail.add_pseudoheader(:error, I18n.t("plugins.resend.not_resent_no_keys", email: email, usable_keys: usable_keys_size, all_keys: all_keys_size))
def self.add_resend_msg(mail, email, severity, msg, usable_keys_size, all_keys_size)
mail.add_pseudoheader(severity, I18n.t("plugins.resend.#{msg}", email: email, usable_keys: usable_keys_size, all_keys: all_keys_size))
end
def self.add_error_header(mail, recipients_map)
......
......@@ -122,6 +122,7 @@ de:
X-FETCH-KEY: https://example.org/keys/mykey.asc
resend:
not_resent_no_keys: Resending an <%{email}> fehlgeschlagen (%{all_keys} Schlüssel gefunden, davon %{usable_keys} nutzbar. Unverschlüsseltes Senden verboten).
not_resent_encrypted_no_keys: Verschlüsseltes Resending an <%{email}> fehlgeschlagen (%{all_keys} Schlüssel gefunden, davon %{usable_keys} nutzbar).
encrypted_to: Verschlüsselt an
unencrypted_to: Unverschlüsselt an
invalid_recipient: "Ungültige Emailadresse für resend: %{address}"
......
......@@ -126,6 +126,7 @@ en:
X-FETCH-KEY: https://example.org/keys/mykey.asc
resend:
not_resent_no_keys: Resending to <%{email}> failed (%{all_keys} keys found, of which %{usable_keys} can be used. Unencrypted sending not allowed).
not_resent_encrypted_no_keys: Resending as encrypted email to <%{email}> failed (%{all_keys} keys found, of which %{usable_keys} can be used).
encrypted_to: Encrypted to
unencrypted_to: Unencrypted to
invalid_recipient: "Invalid email-address for resending: %{address}"
......
......@@ -2133,7 +2133,7 @@ EOS
message = Mail.create_message_to_list(raw.to_s, list.email, list).setup
expect(list.keys('bla@foo').size).to eql(1)
expect(message.first_plaintext_part.to_s).to include("Resending to <bla@foo> failed (0 usable of totally 1 keys found")
expect(message.first_plaintext_part.to_s).to include("Error: Resending to <bla@foo> failed (1 keys found, of which 0 can be used.\r\n Unencrypted sending not allowed).")
teardown_list_and_mailer(list)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment