action_recipient 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/action_recipient/configuration.rb +18 -2
- data/lib/action_recipient/rewriter.rb +5 -1
- data/lib/action_recipient/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8494299046a94fa75e5f75127e0c3854e0af1da065108c7d8c61c39be550e8af
|
4
|
+
data.tar.gz: a533cd9ad625688c008be2d95d6d493b57e4bc7c584d4168e58e87c999e4e74d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 491a5b5e79f2a6fe708239a1d89a4dc0d82ac4e92deac38bbb5f08993151e65f6777dc412d46e055c1cccac0c6d3c27ba880631f3bc0b5cbd154e2b5aff686d5
|
7
|
+
data.tar.gz: 8f2c371001d334168b1ee11622b4e1104b86ef51eb9e2a1859aaad7d12bf6704c13fbc82bcd29fd7dc1dfa7a0405c9d3abc413be7621538bae7206f4903b0b13
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ if Rails.env.staging? # works only in staging environment
|
|
46
46
|
ActionRecipient.configure do |config|
|
47
47
|
config.format = 'your_address_to_redirect+%s@gmail.com'
|
48
48
|
|
49
|
-
config.whitelist = [
|
49
|
+
config.whitelist.addresses = [
|
50
50
|
'safe_address@example.com',
|
51
51
|
'my_personal_adddress@example.com'
|
52
52
|
]
|
@@ -74,19 +74,29 @@ If you add **%s** in the format, it is automatically replaced with the original
|
|
74
74
|
|
75
75
|
**DO NOT FORGET to specify a format**, otherwise your email addresses are not properly transformed, and your emails will not be successfully delivered.
|
76
76
|
|
77
|
-
2. you could also set a collection of whitelisted
|
77
|
+
2. you could also set a collection of whitelisted addresses and/or domains:
|
78
78
|
|
79
79
|
```ruby
|
80
80
|
ActionRecipient.configure do |config|
|
81
|
-
config.whitelist = [
|
81
|
+
config.whitelist.addresses = [
|
82
82
|
'my_personal_address@example.com',
|
83
83
|
'my_colleagues_address@example.com'
|
84
84
|
]
|
85
|
+
|
86
|
+
config.whitelist.domains = [
|
87
|
+
'my_office_domain.com',
|
88
|
+
'subdomain.my_office_domain.com'
|
89
|
+
]
|
85
90
|
end
|
86
91
|
```
|
87
92
|
|
88
93
|
Whitelisted emails addresses are not overwritten, thus can be delivered as usual.
|
89
94
|
|
95
|
+
IMPORTANT:
|
96
|
+
With current version (version <~ 0.2.0) "domains" are the last part of email addresses after `@`, and matched with original email address literally on word-to-word basis.
|
97
|
+
|
98
|
+
So whitelisted domains such as `bar.com` does NOT whitelist emails to subdomains like `somebody@foo.bar.com` (therefore redirected).
|
99
|
+
|
90
100
|
3. register ActionRecipient as the interceptor
|
91
101
|
|
92
102
|
```ruby
|
@@ -14,14 +14,30 @@ module ActionRecipient
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class Configuration
|
17
|
-
attr_writer :
|
17
|
+
attr_writer :format
|
18
18
|
|
19
19
|
def whitelist
|
20
|
-
@whitelist ||=
|
20
|
+
@whitelist ||= Whitelist.new
|
21
21
|
end
|
22
22
|
|
23
23
|
def format
|
24
24
|
@format ||= '%s'
|
25
25
|
end
|
26
|
+
|
27
|
+
class Whitelist
|
28
|
+
attr_writer :domains, :addresses
|
29
|
+
|
30
|
+
def [](key)
|
31
|
+
public_send(key) if %i[domains addresses].include? key
|
32
|
+
end
|
33
|
+
|
34
|
+
def domains
|
35
|
+
@domains ||= []
|
36
|
+
end
|
37
|
+
|
38
|
+
def addresses
|
39
|
+
@addresses ||= []
|
40
|
+
end
|
41
|
+
end
|
26
42
|
end
|
27
43
|
end
|
@@ -19,7 +19,7 @@ module ActionRecipient
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def whitelisted?(email)
|
22
|
-
whitelist.include? email
|
22
|
+
whitelist.addresses.include?(email) || whitelist.domains.include?(domain_for(email))
|
23
23
|
end
|
24
24
|
|
25
25
|
def whitelist
|
@@ -29,6 +29,10 @@ module ActionRecipient
|
|
29
29
|
def format
|
30
30
|
ActionRecipient.config.format
|
31
31
|
end
|
32
|
+
|
33
|
+
def domain_for(email)
|
34
|
+
email.split('@').last
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|