Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emails to suppression list #6155

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ gem 'mongo'
gem 'aws-sdk-s3', '~> 1'
gem 'aws-sdk-ecr'
gem 'aws-sdk-cloudfront'
gem 'aws-sdk-sesv2'
gem 'anycable-rails', '~> 1.2.0'
gem 'grpc', '>= 1.53.0'
gem 'crawler_detect'
Expand All @@ -38,7 +39,7 @@ gem 'kaminari'
gem 'oj', '~> 3.14.0'

# Setup dependencies
gem 'exercism-config', '>= 0.114.0'
gem 'exercism-config', '>= 0.115.0'
# gem 'exercism-config', path: '../config'

# Model-level dependencies
Expand Down
8 changes: 6 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ GEM
aws-sdk-secretsmanager (1.75.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-sesv2 (1.33.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
backport (1.2.0)
Expand Down Expand Up @@ -168,7 +171,7 @@ GEM
erubi (1.12.0)
et-orbi (1.2.7)
tzinfo
exercism-config (0.114.0)
exercism-config (0.115.0)
aws-sdk-dynamodb (~> 1.0)
aws-sdk-secretsmanager (~> 1.0)
mandate
Expand Down Expand Up @@ -549,6 +552,7 @@ DEPENDENCIES
aws-sdk-cloudfront
aws-sdk-ecr
aws-sdk-s3 (~> 1)
aws-sdk-sesv2
bootsnap (>= 1.4.2)
bugsnag
bullet
Expand All @@ -560,7 +564,7 @@ DEPENDENCIES
cssbundling-rails
devise (~> 4.7)
discourse_api
exercism-config (>= 0.114.0)
exercism-config (>= 0.115.0)
factory_bot_rails
friendly_id (~> 5.4.0)
geocoder (~> 1.8)
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/spi/unsubscribe_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ class UnsubscribeUsersController < BaseController
def unsubscribe_by_email
user = User.find_by!(email: params[:email])
User::UnsubscribeFromAllEmails.(user)

Exercism.ses_client.put_suppressed_destination({
email_address: params[:email],
reason: params[:reason].upcase
})
end
end
end
10 changes: 9 additions & 1 deletion test/controllers/spi/unsubscribe_user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ class SPI::UnsubscribeUserTest < ActionDispatch::IntegrationTest
test "unsubscribes correctly" do
user = create :user

client = mock
Exercism.expects(:ses_client).returns(client)
client.expects(:put_suppressed_destination).with({
email_address: user.email,
reason: "BOUNCE"
})

User::UnsubscribeFromAllEmails.expects(:call).with(user)

patch spi_unsubscribe_user_path(
email: user.email
email: user.email,
reason: :bounce
)
end
end