mailkick 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +11 -1
- data/app/controllers/mailkick/subscriptions_controller.rb +8 -1
- data/config/routes.rb +1 -1
- data/lib/mailkick/url_helper.rb +6 -1
- data/lib/mailkick/version.rb +1 -1
- data/lib/mailkick.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9cc5e031a75a29b20c985acb8b16922338dab5e65a1df97818facd9a94c75e3
|
4
|
+
data.tar.gz: 433257564c2918ad55eeb41efc5219e86720d2d29bca3808ff084ba76a085524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c28e41447543e5498ca2f91fa66e1e0cf1dce16160d76d73b883be236f8a5d36091c2e768d3f5668702a371759891e1a3a5187f4a440cb35b313f9021734908
|
7
|
+
data.tar.gz: 1fe58111dc7a26644d68a425be18824a660cf16c4305207c8b63ae8916609381d376a72bd449b4e21b02fe1541e571a210b0086d7947b764e619ed67a3f8a5dd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Email subscriptions for Rails
|
4
4
|
|
5
|
-
- Add one-click unsubscribe links to your emails
|
5
|
+
- Add one-click unsubscribe links and headers to your emails
|
6
6
|
- Fetch bounces and spam reports from your email service
|
7
7
|
|
8
8
|
:postbox: Check out [Ahoy Email](https://github.com/ankane/ahoy_email) for analytics
|
@@ -81,6 +81,16 @@ rails generate mailkick:views
|
|
81
81
|
|
82
82
|
which copies the view into `app/views/mailkick`.
|
83
83
|
|
84
|
+
## Unsubscribe Headers
|
85
|
+
|
86
|
+
For one-click unsubscribe headers ([RFC 8058](https://datatracker.ietf.org/doc/html/rfc8058)), create `config/initializers/mailkick.rb` with:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
Mailkick.headers = true
|
90
|
+
```
|
91
|
+
|
92
|
+
Headers will automatically be added to emails that call `mailkick_unsubscribe_url`.
|
93
|
+
|
84
94
|
## Bounces and Spam Reports
|
85
95
|
|
86
96
|
Fetch bounces, spam reports, and unsubscribes from your email service. Create `config/initializers/mailkick.rb` with a method to handle opt outs.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Mailkick
|
2
2
|
class SubscriptionsController < ActionController::Base
|
3
3
|
protect_from_forgery with: :exception
|
4
|
+
skip_forgery_protection only: [:unsubscribe]
|
4
5
|
|
5
6
|
before_action :set_subscription
|
6
7
|
|
@@ -12,7 +13,13 @@ module Mailkick
|
|
12
13
|
|
13
14
|
Mailkick::Legacy.opt_out(legacy_options) if Mailkick::Legacy.opt_outs?
|
14
15
|
|
15
|
-
|
16
|
+
if request.post? && params["List-Unsubscribe"] == "One-Click"
|
17
|
+
# must not redirect according to RFC 8058
|
18
|
+
# could render show action instead
|
19
|
+
render plain: "Unsubscribe successful"
|
20
|
+
else
|
21
|
+
redirect_to subscription_path(params[:id])
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
def subscribe
|
data/config/routes.rb
CHANGED
data/lib/mailkick/url_helper.rb
CHANGED
@@ -2,7 +2,12 @@ module Mailkick
|
|
2
2
|
module UrlHelper
|
3
3
|
def mailkick_unsubscribe_url(subscriber, list, **options)
|
4
4
|
token = Mailkick.generate_token(subscriber, list)
|
5
|
-
mailkick.unsubscribe_subscription_url(token, **options)
|
5
|
+
url = mailkick.unsubscribe_subscription_url(token, **options)
|
6
|
+
if Mailkick.headers && headers["List-Unsubscribe"].nil?
|
7
|
+
headers["List-Unsubscribe-Post"] ||= "List-Unsubscribe=One-Click"
|
8
|
+
headers["List-Unsubscribe"] = "<#{url}>"
|
9
|
+
end
|
10
|
+
url
|
6
11
|
end
|
7
12
|
end
|
8
13
|
end
|
data/lib/mailkick/version.rb
CHANGED
data/lib/mailkick.rb
CHANGED
@@ -24,12 +24,13 @@ require_relative "mailkick/version"
|
|
24
24
|
require_relative "mailkick/engine" if defined?(Rails)
|
25
25
|
|
26
26
|
module Mailkick
|
27
|
-
mattr_accessor :services, :mount, :process_opt_outs_method
|
27
|
+
mattr_accessor :services, :mount, :process_opt_outs_method, :headers
|
28
28
|
mattr_reader :secret_token
|
29
29
|
mattr_writer :message_verifier
|
30
30
|
self.services = []
|
31
31
|
self.mount = true
|
32
32
|
self.process_opt_outs_method = ->(_) { raise "process_opt_outs_method not defined" }
|
33
|
+
self.headers = false
|
33
34
|
|
34
35
|
def self.fetch_opt_outs
|
35
36
|
services.each(&:fetch_opt_outs)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.5.3
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Email subscriptions for Rails
|