Skip to content

Commit

Permalink
Keep gmail happy by allowing one click post unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Jan 31, 2024
1 parent ddc95d1 commit 3d105fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/mailers/alert_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def alert(alert:, applications: [], comments: [])
@comments = T.let(comments, T.nilable(T::Array[Comment]))

headers(
# The List-Unsubscribe header appears not to be working in gmail anymore
# TODO: Figure out what's going on. Is it fixable?
# The unsubscribe URL needs to accept a post
"List-Unsubscribe-Post" => "List-Unsubscribe=One-Click",
"List-Unsubscribe" => "<#{unsubscribe_alert_url(confirm_id: alert.confirm_id)}>",
# This special header sets arbitrary metadata on the email in Cuttlefish
# It's not sent on in the outgoing email
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def matches?(request)
resources :alerts, only: %i[new create], path_names: { new: "signup" }, param: :confirm_id do
member do
get :unsubscribe
post :unsubscribe
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/mailers/alert_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

it "has the unsubscribe header" do
expect(email.header["List-Unsubscribe"].to_s).to eq("<https://dev.planningalerts.org.au/alerts/abcdef/unsubscribe>")
expect(email.header["List-Unsubscribe-Post"].to_s).to eq("List-Unsubscribe=One-Click")
end
end

Expand Down

0 comments on commit 3d105fc

Please sign in to comment.