ahoy_email 2.1.0 → 2.1.1
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 +4 -0
- data/README.md +11 -4
- data/lib/ahoy_email/version.rb +1 -1
- data/lib/generators/ahoy/messages/activerecord_generator.rb +26 -5
- data/lib/generators/ahoy/messages/mongoid_generator.rb +22 -2
- data/lib/generators/ahoy/messages/templates/model_activerecord.rb.tt +7 -0
- data/lib/generators/ahoy/messages/templates/{model_encrypted.rb.tt → model_lockbox.rb.tt} +0 -0
- data/lib/generators/ahoy/messages/templates/{mongoid_encrypted.rb.tt → mongoid_lockbox.rb.tt} +0 -0
- data/lib/generators/ahoy/messages_generator.rb +2 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf88f44f04ee798926e9363928aed4be7c34d0b4f5456b01f1dc210f18967cc4
|
4
|
+
data.tar.gz: bb0c2ea92f067cbd6f37f7d06bb7700f51427dd68f178d0405ccf31f02b21fea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9568577466f777d12ad274926490b72f0976eec913b12e8e524f3af66612f22a9a07fa5065c5e2f8817b735ee4ed683a2391b62211aadda716168b3b12833f4b
|
7
|
+
data.tar.gz: 122f4e7758d69d4cba1c16b3ff677317084b562921db52d7bcd9408b760aa5ef3e5ebd61808e04e39c1f6e538722d51247daba68037bad88939338049db6f80e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,17 +28,24 @@ There are three main features, which can be used independently:
|
|
28
28
|
|
29
29
|
## Message History
|
30
30
|
|
31
|
-
To encrypt email addresses, install [Lockbox](https://github.com/ankane/lockbox) and [Blind Index](https://github.com/ankane/blind_index) and run:
|
31
|
+
To encrypt email addresses with Lockbox, install [Lockbox](https://github.com/ankane/lockbox) and [Blind Index](https://github.com/ankane/blind_index) and run:
|
32
32
|
|
33
33
|
```sh
|
34
|
-
rails generate ahoy:messages
|
34
|
+
rails generate ahoy:messages --encryption=lockbox
|
35
|
+
rails db:migrate
|
36
|
+
```
|
37
|
+
|
38
|
+
To use Active Record encryption (Rails 7+, experimental), run:
|
39
|
+
|
40
|
+
```sh
|
41
|
+
rails generate ahoy:messages --encryption=activerecord
|
35
42
|
rails db:migrate
|
36
43
|
```
|
37
44
|
|
38
45
|
If you prefer not to encrypt data, run:
|
39
46
|
|
40
47
|
```sh
|
41
|
-
rails generate ahoy:messages --
|
48
|
+
rails generate ahoy:messages --encryption=none
|
42
49
|
rails db:migrate
|
43
50
|
```
|
44
51
|
|
@@ -157,7 +164,7 @@ Ahoy::Message.where("created_at < ?", 1.year.ago).in_batches.delete_all
|
|
157
164
|
Delete data for a specific user with:
|
158
165
|
|
159
166
|
```ruby
|
160
|
-
Ahoy::Message.where(user_id: 1).in_batches.delete_all
|
167
|
+
Ahoy::Message.where(user_id: 1, user_type: "User").in_batches.delete_all
|
161
168
|
```
|
162
169
|
|
163
170
|
## UTM Tagging
|
data/lib/ahoy_email/version.rb
CHANGED
@@ -7,15 +7,21 @@ module Ahoy
|
|
7
7
|
include ActiveRecord::Generators::Migration
|
8
8
|
source_root File.join(__dir__, "templates")
|
9
9
|
|
10
|
+
class_option :encryption, type: :string
|
11
|
+
# deprecated
|
10
12
|
class_option :unencrypted, type: :boolean
|
11
13
|
|
12
14
|
def copy_migration
|
15
|
+
encryption # ensure valid
|
13
16
|
migration_template "migration.rb", "db/migrate/create_ahoy_messages.rb", migration_version: migration_version
|
14
17
|
end
|
15
18
|
|
16
19
|
def copy_template
|
17
|
-
|
18
|
-
|
20
|
+
case encryption
|
21
|
+
when "lockbox"
|
22
|
+
template "model_lockbox.rb", "app/models/ahoy/message.rb"
|
23
|
+
when "activerecord"
|
24
|
+
template "model_activerecord.rb", "app/models/ahoy/message.rb"
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
@@ -24,15 +30,30 @@ module Ahoy
|
|
24
30
|
end
|
25
31
|
|
26
32
|
def to_column
|
27
|
-
|
33
|
+
case encryption
|
34
|
+
when "lockbox"
|
28
35
|
"t.text :to_ciphertext\n t.string :to_bidx, index: true"
|
29
36
|
else
|
37
|
+
# TODO add limit: 510 for Active Record encryption + MySQL?
|
30
38
|
"t.string :to, index: true"
|
31
39
|
end
|
32
40
|
end
|
33
41
|
|
34
|
-
|
35
|
-
|
42
|
+
# TODO remove default
|
43
|
+
def encryption
|
44
|
+
case options[:encryption]
|
45
|
+
when "lockbox", "activerecord", "none"
|
46
|
+
options[:encryption]
|
47
|
+
when nil
|
48
|
+
if options[:unencrypted]
|
49
|
+
# TODO deprecation warning
|
50
|
+
"none"
|
51
|
+
else
|
52
|
+
"lockbox"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
abort "Error: encryption must be lockbox, activerecord, or none"
|
56
|
+
end
|
36
57
|
end
|
37
58
|
end
|
38
59
|
end
|
@@ -6,13 +6,33 @@ module Ahoy
|
|
6
6
|
class MongoidGenerator < Rails::Generators::Base
|
7
7
|
source_root File.join(__dir__, "templates")
|
8
8
|
|
9
|
+
class_option :encryption, type: :string
|
10
|
+
# deprecated
|
9
11
|
class_option :unencrypted, type: :boolean
|
10
12
|
|
11
13
|
def copy_templates
|
12
|
-
|
14
|
+
case encryption
|
15
|
+
when "lockbox"
|
16
|
+
template "mongoid_lockbox.rb", "app/models/ahoy/message.rb"
|
17
|
+
else
|
13
18
|
template "mongoid.rb", "app/models/ahoy/message.rb"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO remove default
|
23
|
+
def encryption
|
24
|
+
case options[:encryption]
|
25
|
+
when "lockbox", "none"
|
26
|
+
options[:encryption]
|
27
|
+
when nil
|
28
|
+
if options[:unencrypted]
|
29
|
+
# TODO deprecation warning
|
30
|
+
"none"
|
31
|
+
else
|
32
|
+
"lockbox"
|
33
|
+
end
|
14
34
|
else
|
15
|
-
|
35
|
+
abort "Error: encryption must be lockbox or none"
|
16
36
|
end
|
17
37
|
end
|
18
38
|
end
|
File without changes
|
data/lib/generators/ahoy/messages/templates/{mongoid_encrypted.rb.tt → mongoid_lockbox.rb.tt}
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -99,9 +99,10 @@ files:
|
|
99
99
|
- lib/generators/ahoy/messages/activerecord_generator.rb
|
100
100
|
- lib/generators/ahoy/messages/mongoid_generator.rb
|
101
101
|
- lib/generators/ahoy/messages/templates/migration.rb.tt
|
102
|
-
- lib/generators/ahoy/messages/templates/
|
102
|
+
- lib/generators/ahoy/messages/templates/model_activerecord.rb.tt
|
103
|
+
- lib/generators/ahoy/messages/templates/model_lockbox.rb.tt
|
103
104
|
- lib/generators/ahoy/messages/templates/mongoid.rb.tt
|
104
|
-
- lib/generators/ahoy/messages/templates/
|
105
|
+
- lib/generators/ahoy/messages/templates/mongoid_lockbox.rb.tt
|
105
106
|
- lib/generators/ahoy/messages_generator.rb
|
106
107
|
homepage: https://github.com/ankane/ahoy_email
|
107
108
|
licenses:
|
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
123
|
- !ruby/object:Gem::Version
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
|
-
rubygems_version: 3.2.
|
126
|
+
rubygems_version: 3.2.32
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: First-party email analytics for Rails
|