Commit 89d60b0b authored by ng's avatar ng
Browse files

Merge branch...

Merge branch '354-admins-with-delivery_enabled-false-are-not-getting-results-of-mails-they-send-to-request-address' into 'master'

Resolve "Admins with delivery_enabled=false are not getting results of mails they send to -request-address"

Closes #354

See merge request schleuder/schleuder!200
parents afe28266 71d3584a
......@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
* Handle missing arguments for several keywords and reply with a helpful error-message.
* Send replies to keyword-usage and notices to admins regardless of the delivery-flag of their subscription. (#354)
### Changed
......
......@@ -345,7 +345,11 @@ module Schleuder
mail.add_internal_footer!
self.subscriptions.each do |subscription|
begin
subscription.send_mail(mail)
if subscription.delivery_enabled
subscription.send_mail(mail)
else
logger.info "Not sending to #{subscription.email}: delivery is disabled."
end
rescue => exc
msg = I18n.t('errors.delivery_error',
{ email: subscription.email, error: exc.to_s })
......
......@@ -40,11 +40,6 @@ module Schleuder
def send_mail(mail)
list.logger.debug "Preparing sending to #{self.inspect}"
if ! self.delivery_enabled
list.logger.info "Not sending to #{self.email}: delivery is disabled."
return false
end
mail = ensure_headers(mail)
gpg_opts = self.list.gpg_sign_options
......
......@@ -1553,6 +1553,48 @@ describe "user sends keyword" do
teardown_list_and_mailer(list)
end
it "x-resend with admin-notification and admin has delivery disabled" do
list = create(:list, keywords_admin_notify: ['resend'])
list.subscribe("user@example.org", "59C71FB38AEE22E091C78259D06350440F759BD3")
list.subscribe("admin@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true, false)
ENV['GNUPGHOME'] = list.listdir
mail = Mail.new
mail.to = list.email
mail.from = list.admins.first.email
gpg_opts = {
encrypt: true,
keys: {list.email => list.fingerprint},
sign: true,
sign_as: list.admins.first.fingerprint
}
mail.gpg(gpg_opts)
content_body = "Hello again!\n"
mail.body = "x-list-name: #{list.email}\nX-resend: someone@example.org\n#{content_body}"
mail.deliver
encrypted_mail = Mail::TestMailer.deliveries.first
Mail::TestMailer.deliveries.clear
begin
Schleuder::Runner.new().run(encrypted_mail.to_s, list.email)
rescue SystemExit
end
raw = Mail::TestMailer.deliveries[1]
notification = Mail.create_message_to_list(raw.to_s, list.email, list).setup
raw = Mail::TestMailer.deliveries[2]
message = Mail.create_message_to_list(raw.to_s, list.email, list).setup
expect(Mail::TestMailer.deliveries.size).to eql(3)
expect(notification.to).to eql(['admin@example.org'])
expect(notification.first_plaintext_part.body.to_s).to eql("admin@example.org used the keyword 'resend' with the values 'someone@example.org' in a message sent to the list.")
expect(message.to).to eql(['user@example.org'])
expect(message.to_s).to include("Resent: Unencrypted to someone@example.org")
teardown_list_and_mailer(list)
end
it "x-resend without x-list-name" do
list = create(:list)
list.subscribe("schleuder@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true)
......@@ -2383,6 +2425,40 @@ describe "user sends keyword" do
teardown_list_and_mailer(list)
end
it "x-get-version with delivery disabled" do
list = create(:list)
list.subscribe("schleuder@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true, false)
ENV['GNUPGHOME'] = list.listdir
mail = Mail.new
mail.to = list.request_address
mail.from = list.admins.first.email
gpg_opts = {
encrypt: true,
keys: {list.request_address => list.fingerprint},
sign: true,
sign_as: list.admins.first.fingerprint
}
mail.gpg(gpg_opts)
mail.body = "x-listname: #{list.email}\nX-get-version"
mail.deliver
encrypted_mail = Mail::TestMailer.deliveries.first
Mail::TestMailer.deliveries.clear
begin
Schleuder::Runner.new().run(encrypted_mail.to_s, list.request_address)
rescue SystemExit
end
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.to).to eql(['schleuder@example.org'])
expect(message.first_plaintext_part.body.to_s.lines.size).to eql(1)
expect(message.first_plaintext_part.body.to_s).to eql(Schleuder::VERSION)
teardown_list_and_mailer(list)
end
it "x-list-keys without arguments" do
list = create(:list)
list.subscribe("schleuder@example.org", '59C71FB38AEE22E091C78259D06350440F759BD3', true)
......
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