...
 
......@@ -17,7 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
* To remove a fingerprint from a subscription one can use the new keyword X-UNSET-FINGERPRINT (#360).
* `deliver_selfsent` per-list opton to control whether subscribers get a copy of mail they sent themselves. (#365)
### Changed
......
class AddDeliverSelfSentToList < ActiveRecord::Migration
def up
if ! column_exists?(:lists, :deliver_selfsent)
add_column :lists, :deliver_selfsent, :boolean, default: true
end
end
def down
remove_column(:lists, :deliver_selfsent)
end
end
......@@ -37,6 +37,7 @@ ActiveRecord::Schema.define(version: 20170713215059) do
t.boolean "keep_msgid", default: true
t.boolean "bounces_drop_all", default: false
t.boolean "bounces_notify_admins", default: true
t.boolean "deliver_selfsent", default: true
t.boolean "include_list_headers", default: true
t.boolean "include_openpgp_header", default: true
t.integer "max_message_size_kb", default: 10240
......
......@@ -123,3 +123,8 @@ language: en
# Forward a raw copy of all incoming emails to the list-admins?
# Mainly useful for debugging.
forward_all_incoming_to_admins: false
# Should e-mails be delivered to the original subscribed sender?
# Disabling this only works for signed e-mails; any e-mail that is unsigned
# sent to the list is treated as coming from an unknown source
deliver_selfsent: true
......@@ -19,6 +19,7 @@ module Schleuder
:receive_admin_only,
:keep_msgid,
:bounces_drop_all,
:deliver_selfsent,
:bounces_notify_admins,
:include_list_headers,
:include_openpgp_header,
......@@ -345,11 +346,19 @@ module Schleuder
mail.add_internal_footer!
self.subscriptions.each do |subscription|
begin
if subscription.delivery_enabled
subscription.send_mail(mail)
else
if ! subscription.delivery_enabled
logger.info "Not sending to #{subscription.email}: delivery is disabled."
next
end
if ! self.deliver_selfsent && mail.was_validly_signed? && ( subscription == mail.signer ) )
logger.info "Not sending to #{subscription.email}: delivery of self sent is disabled."
next
end
subscription.send_mail(mail)
rescue => exc
msg = I18n.t('errors.delivery_error',
{ email: subscription.email, error: exc.to_s })
......
......@@ -22,6 +22,7 @@ FactoryBot.define do
keep_msgid true
bounces_drop_all false
bounces_notify_admins true
deliver_selfsent true
include_list_headers true
include_openpgp_header true
max_message_size_kb 10240
......
......@@ -63,6 +63,7 @@ describe 'cli' do
expect(list.keep_msgid).to eq true
expect(list.bounces_drop_all).to eq false
expect(list.bounces_notify_admins).to eq true
expect(list.deliver_selfsent).to eq true
expect(list.include_list_headers).to eq true
expect(list.include_openpgp_header).to eq true
expect(list.openpgp_header_preference).to eq 'signencrypt'
......
......@@ -6,8 +6,8 @@ describe Schleuder::List do
:send_encrypted_only, :receive_encrypted_only, :receive_signed_only,
:receive_authenticated_only, :receive_from_subscribed_emailaddresses_only,
:receive_admin_only, :keep_msgid, :bounces_drop_all,
:bounces_notify_admins, :include_list_headers, :include_list_headers,
:include_openpgp_header, :forward_all_incoming_to_admins
:bounces_notify_admins, :deliver_selfsent, :include_list_headers,
:include_list_headers, :include_openpgp_header, :forward_all_incoming_to_admins
].freeze
it "has a valid factory" do
......@@ -39,6 +39,7 @@ describe Schleuder::List do
it { is_expected.to respond_to :keep_msgid }
it { is_expected.to respond_to :bounces_drop_all }
it { is_expected.to respond_to :bounces_notify_admins }
it { is_expected.to respond_to :deliver_selfsent }
it { is_expected.to respond_to :include_list_headers }
it { is_expected.to respond_to :include_openpgp_header }
it { is_expected.to respond_to :max_message_size_kb }
......@@ -196,7 +197,7 @@ describe Schleuder::List do
describe ".configurable_attributes" do
it "returns an array that contains the configurable attributes" do
expect(Schleuder::List.configurable_attributes).to eq [
:bounces_drop_all, :bounces_drop_on_headers, :bounces_notify_admins,
:bounces_drop_all, :bounces_drop_on_headers, :bounces_notify_admins, :deliver_selfsent,
:forward_all_incoming_to_admins, :headers_to_meta, :include_list_headers,
:include_openpgp_header, :internal_footer, :keep_msgid, :keywords_admin_notify, :keywords_admin_only,
:language, :log_level, :logfiles_to_keep, :max_message_size_kb, :openpgp_header_preference,
......