mailkick 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -63
- data/lib/mailkick/engine.rb +1 -1
- data/lib/mailkick/legacy.rb +1 -1
- data/lib/mailkick/model.rb +1 -1
- data/lib/mailkick/service/postmark.rb +1 -1
- data/lib/mailkick/version.rb +1 -1
- metadata +6 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f16bb5b552006639122c94a4b910982ed0845694bb503dfac08e23e3ed41f24
|
4
|
+
data.tar.gz: c82b3290c80af68f5d9817a38a4d30af8d5893a216121154182457d96f0904dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a31f0bb8e3a84e0abcc6bca052a815fd4f98eb8130572903e010d479bc3e46c219ea0efb4b89cfba09d8cb3e7fd68a42f7c99716a1e4228ea9b65af6e663b21e
|
7
|
+
data.tar.gz: e9e0cc2fac1d027ee28650077977d30abcce514e4064eb27b73e0650147828f292bcae32631cdb600271b9a5e50ddd24603e1d328231a1227d523571cfdb003c
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Email subscriptions for Rails
|
|
7
7
|
|
8
8
|
:postbox: Check out [Ahoy Email](https://github.com/ankane/ahoy_email) for analytics
|
9
9
|
|
10
|
-
[](https://github.com/ankane/mailkick/actions)
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -209,68 +209,6 @@ Access the subscription model directly
|
|
209
209
|
Mailkick::Subscription.all
|
210
210
|
```
|
211
211
|
|
212
|
-
## Upgrading
|
213
|
-
|
214
|
-
### 1.0
|
215
|
-
|
216
|
-
Mailkick 1.0 stores subscriptions instead of opt-outs. To migrate:
|
217
|
-
|
218
|
-
1. Add a table to store subscriptions
|
219
|
-
|
220
|
-
```sh
|
221
|
-
rails generate mailkick:install
|
222
|
-
rails db:migrate
|
223
|
-
```
|
224
|
-
|
225
|
-
2. Change the following methods in your code:
|
226
|
-
|
227
|
-
- `mailkick_user` to `has_subscriptions`
|
228
|
-
- `User.not_opted_out` to `User.subscribed(list)`
|
229
|
-
- `opt_in` to `subscribe(list)`
|
230
|
-
- `opt_out` to `unsubscribe(list)`
|
231
|
-
- `opted_out?` to `!subscribed?(list)`
|
232
|
-
|
233
|
-
3. Add a user and list to `mailkick_unsubscribe_url`
|
234
|
-
|
235
|
-
```ruby
|
236
|
-
mailkick_unsubscribe_url(user, list)
|
237
|
-
```
|
238
|
-
|
239
|
-
4. Migrate data for each of your lists
|
240
|
-
|
241
|
-
```ruby
|
242
|
-
opted_out_emails = Mailkick::Legacy.opted_out_emails(list: nil)
|
243
|
-
opted_out_users = Mailkick::Legacy.opted_out_users(list: nil)
|
244
|
-
|
245
|
-
User.find_in_batches do |users|
|
246
|
-
users.reject! { |u| opted_out_emails.include?(u.email) }
|
247
|
-
users.reject! { |u| opted_out_users.include?(u) }
|
248
|
-
|
249
|
-
now = Time.now
|
250
|
-
records =
|
251
|
-
users.map do |user|
|
252
|
-
{
|
253
|
-
subscriber_type: user.class.name,
|
254
|
-
subscriber_id: user.id,
|
255
|
-
list: "sales",
|
256
|
-
created_at: now,
|
257
|
-
updated_at: now
|
258
|
-
}
|
259
|
-
end
|
260
|
-
|
261
|
-
# use create! for Active Record < 6
|
262
|
-
Mailkick::Subscription.insert_all!(records)
|
263
|
-
end
|
264
|
-
```
|
265
|
-
|
266
|
-
5. Drop the `mailkick_opt_outs` table
|
267
|
-
|
268
|
-
```ruby
|
269
|
-
drop_table :mailkick_opt_outs
|
270
|
-
```
|
271
|
-
|
272
|
-
Also, if you use `Mailkick.fetch_opt_outs`, [add a method](#bounces-and-spam-reports) to handle opt outs.
|
273
|
-
|
274
212
|
## History
|
275
213
|
|
276
214
|
View the [changelog](https://github.com/ankane/mailkick/blob/master/CHANGELOG.md)
|
data/lib/mailkick/engine.rb
CHANGED
@@ -13,7 +13,7 @@ module Mailkick
|
|
13
13
|
creds =
|
14
14
|
if app.respond_to?(:credentials) && app.credentials.secret_key_base
|
15
15
|
app.credentials
|
16
|
-
elsif app.respond_to?(:secrets)
|
16
|
+
elsif app.respond_to?(:secrets) && app.config.paths["config/secrets"].existent.any?
|
17
17
|
app.secrets
|
18
18
|
else
|
19
19
|
app.config
|
data/lib/mailkick/legacy.rb
CHANGED
@@ -3,7 +3,7 @@ module Mailkick
|
|
3
3
|
# checks for table as long as it exists
|
4
4
|
def self.opt_outs?
|
5
5
|
unless defined?(@opt_outs) && @opt_outs == false
|
6
|
-
@opt_outs = ActiveRecord::Base.
|
6
|
+
@opt_outs = ActiveRecord::Base.connection_pool.with_connection { |c| c.table_exists?("mailkick_opt_outs") }
|
7
7
|
end
|
8
8
|
@opt_outs
|
9
9
|
end
|
data/lib/mailkick/model.rb
CHANGED
@@ -3,7 +3,7 @@ module Mailkick
|
|
3
3
|
def has_subscriptions
|
4
4
|
class_eval do
|
5
5
|
has_many :mailkick_subscriptions, class_name: "Mailkick::Subscription", as: :subscriber
|
6
|
-
scope :subscribed, ->
|
6
|
+
scope :subscribed, ->(list) { joins(:mailkick_subscriptions).where(mailkick_subscriptions: {list: list}) }
|
7
7
|
|
8
8
|
def subscribe(list)
|
9
9
|
mailkick_subscriptions.where(list: list).first_or_create!
|
data/lib/mailkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-03 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -16,15 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '7.1'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
description:
|
25
|
+
version: '7.1'
|
28
26
|
email: andrew@ankane.org
|
29
27
|
executables: []
|
30
28
|
extensions: []
|
@@ -60,7 +58,6 @@ homepage: https://github.com/ankane/mailkick
|
|
60
58
|
licenses:
|
61
59
|
- MIT
|
62
60
|
metadata: {}
|
63
|
-
post_install_message:
|
64
61
|
rdoc_options: []
|
65
62
|
require_paths:
|
66
63
|
- lib
|
@@ -68,15 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
65
|
requirements:
|
69
66
|
- - ">="
|
70
67
|
- !ruby/object:Gem::Version
|
71
|
-
version: '3'
|
68
|
+
version: '3.2'
|
72
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
70
|
requirements:
|
74
71
|
- - ">="
|
75
72
|
- !ruby/object:Gem::Version
|
76
73
|
version: '0'
|
77
74
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
-
signing_key:
|
75
|
+
rubygems_version: 3.6.2
|
80
76
|
specification_version: 4
|
81
77
|
summary: Email subscriptions for Rails
|
82
78
|
test_files: []
|