Commit 711916e8 authored by ng's avatar ng

fix #429 - say how many keys were found and how many were usable

parent a6137e4d
......@@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](
* Add missing List-Id header to notification mails sent to admins. This should help with filtering such messages, which is currently not easy to do in a reliable way.
* 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)
## [3.4.1] / 2019-09-16
......@@ -117,22 +117,22 @@ module Schleuder
Array(recipients).inject({}) do |hash, email|
keys = mail.list.keys(email)
# Exclude unusable keys.! { |key| key.usable_for?(:encrypt) }
case keys.size
usable_keys = { |key| key.usable_for?(:encrypt) }
case usable_keys.size
when 1
hash[email] = keys.first
hash[email] = usable_keys.first
when 0
if encrypted_only
# Don't add the email to the result to exclude it from the
# recipients.
add_keys_error(mail, email, keys.size)
add_keys_error(mail, email, usable_keys.size, keys.size)
hash[email] = ''
# Always report this situation, regardless of sending or not. It's
# bad and should be fixed.
add_keys_error(mail, email, keys.size)
add_keys_error(mail, email, usable_keys.size, keys.size)
if ! encrypted_only
hash[email] = ''
......@@ -152,8 +152,8 @@ module Schleuder
def self.add_keys_error(mail, email, keys_size)
mail.add_pseudoheader(:error, I18n.t("plugins.resend.not_resent_no_keys", email: email, num_keys: keys_size))
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_error_header(mail, recipients_map)
......@@ -121,7 +121,7 @@ de:
Oder, um einen Schlüssel per HTTP von einem Server zu laden:
not_resent_no_keys: Resending an <%{email}> fehlgeschlagen (%{num_keys} Schlüssel gefunden und unverschlüsseltes Senden verboten).
not_resent_no_keys: Resending an <%{email}> fehlgeschlagen (%{all_keys} Schlüssel gefunden, davon %{usable_keys} nutzbar. Unverschlüsseltes Senden verboten).
encrypted_to: Verschlüsselt an
unencrypted_to: Unverschlüsselt an
invalid_recipient: "Ungültige Emailadresse für resend: %{address}"
......@@ -125,7 +125,7 @@ en:
Or, to fetch a key keys by URL:
not_resent_no_keys: Resending to <%{email}> failed (%{num_keys} keys found and unencrypted sending disallowed).
not_resent_no_keys: Resending to <%{email}> failed (%{all_keys} keys found, of which %{usable_keys} can be used. Unencrypted sending not allowed).
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).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 keys found")
expect(message.first_plaintext_part.to_s).to include("Resending to <bla@foo> failed (0 usable of totally 1 keys found")
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