Skip to content

Commit

Permalink
WIP one click unsub with patched mail-notify
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Dec 5, 2024
1 parent 16bb5de commit ef0050b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gem "omniauth_openid_connect"
gem "omniauth-rails_csrf_protection"

# ActionMailer support for GOV.UK Notify
gem "mail-notify"
gem "mail-notify", github: "asmega/mail-notify", branch: "one-click-unsubscribe"

# Database based asynchronous priority queue system
gem "delayed_job_active_record"
Expand Down
24 changes: 15 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ GIT
multi_xml (~> 0.6.0)
request_store_rails (~> 2)

GIT
remote: https://github.com/asmega/mail-notify.git
revision: bc8c25aa43ebc8d664f3c1760bf05ae9bd96796a
branch: one-click-unsubscribe
specs:
mail-notify (2.0.0)
actionmailer (>= 5.2.8.1)
actionpack (>= 5.2.8.1)
actionview (>= 5.2.8.1)
activesupport (>= 5.2.8.1)
notifications-ruby-client (~> 6.0)
rack (>= 2.1.4.1)

GIT
remote: https://github.com/microsoft/ApplicationInsights-Ruby.git
revision: 5db6b4ad65262d23f26b678143a4a1fd7939e5c2
Expand Down Expand Up @@ -321,13 +334,6 @@ GEM
net-imap
net-pop
net-smtp
mail-notify (2.0.0)
actionmailer (>= 5.2.8.1)
actionpack (>= 5.2.8.1)
actionview (>= 5.2.8.1)
activesupport (>= 5.2.8.1)
notifications-ruby-client (~> 6.0)
rack (>= 2.1.4.1)
marcel (1.0.4)
matrix (0.4.2)
method_source (1.1.0)
Expand Down Expand Up @@ -359,7 +365,7 @@ GEM
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
notifications-ruby-client (6.1.0)
notifications-ruby-client (6.2.0)
jwt (>= 1.5, < 3)
omniauth (2.1.2)
hashie (>= 3.4.6)
Expand Down Expand Up @@ -875,7 +881,7 @@ DEPENDENCIES
jwt
launchy
listen (>= 3.0.5, < 3.10)
mail-notify
mail-notify!
nanoid
omniauth
omniauth-rails_csrf_protection
Expand Down
7 changes: 6 additions & 1 deletion app/mailers/reminder_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def reminder_set(reminder)
to: @reminder.email_address,
reply_to_id: GENERIC_NOTIFY_REPLY_TO_ID,
subject: @subject,
personalisation:
personalisation:,
one_click_unsubscribe_url: one_click_unsubscribe_url(reminder:)
)
end

Expand Down Expand Up @@ -75,6 +76,10 @@ def unsubscribe_url(reminder:)
"https://#{ENV["CANONICAL_HOSTNAME"]}/#{reminder.journey::ROUTING_NAME}/unsubscribe/reminders/#{reminder.id}"
end

def one_click_unsubscribe_url(reminder:)
"https://#{ENV["CANONICAL_HOSTNAME"]}/#{reminder.journey::ROUTING_NAME}/unsubscribe/reminders?id=#{reminder.id}"
end

def extract_first_name(fullname)
(fullname || "").split(" ").first
end
Expand Down

0 comments on commit ef0050b

Please sign in to comment.