effective_messaging 0.5.1 → 0.5.2
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/app/mailers/effective/notifications_mailer.rb +27 -2
- data/lib/effective_messaging/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: 03bcd735271fc2657ea29f9c59b80324d5f869b03b289cdbf3b636204a4c956a
|
4
|
+
data.tar.gz: a6926fb92f8c972c9845489c303d341afbad242e2257b22a6ea061235c1008aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c5a32af19ce69eda8fbf80150a48076b2de2f83bc80ae92ed74f7a3709a70e7b370c19d1667b87a20dee19872de23606df729beda5b3bd322bd605bee23945
|
7
|
+
data.tar.gz: 57c0cc0d79891b0bef5edd279be885de659d7c541c552aff9cbfe58a2ed2480e8601eb8c32f3a78f2d868a9d4a1d058f8684e21cd61cc9f14320034c779186c1
|
@@ -17,7 +17,10 @@ module Effective
|
|
17
17
|
headers = headers_for(notification, opts)
|
18
18
|
|
19
19
|
# Use postmark broadcast-stream
|
20
|
-
|
20
|
+
if defined?(Postmark)
|
21
|
+
headers.merge!(message_stream: 'broadcast-stream')
|
22
|
+
attach_unsubscribe_link!(rendered)
|
23
|
+
end
|
21
24
|
|
22
25
|
# Calls effective_resources subject proc, so we can prepend [LETTERS]
|
23
26
|
subject = subject_for(__method__, rendered.fetch(:subject), notification, opts)
|
@@ -39,7 +42,10 @@ module Effective
|
|
39
42
|
headers = headers_for(notification, opts)
|
40
43
|
|
41
44
|
# Use postmark broadcast-stream
|
42
|
-
|
45
|
+
if defined?(Postmark)
|
46
|
+
headers.merge!(message_stream: 'broadcast-stream')
|
47
|
+
attach_unsubscribe_link!(rendered)
|
48
|
+
end
|
43
49
|
|
44
50
|
# Calls effective_resources subject proc, so we can prepend [LETTERS]
|
45
51
|
subject = subject_for(__method__, rendered.fetch(:subject), resource, opts)
|
@@ -66,6 +72,25 @@ module Effective
|
|
66
72
|
}
|
67
73
|
end
|
68
74
|
|
75
|
+
def attach_unsubscribe_link!(rendered)
|
76
|
+
raise('expected a Hash') unless rendered.kind_of?(Hash)
|
77
|
+
raise('expected a Hash with a :body') unless rendered.key?(:body)
|
78
|
+
|
79
|
+
name = EffectiveResources.et('acronym')
|
80
|
+
url = view_context.root_url
|
81
|
+
|
82
|
+
unsubscribe = [
|
83
|
+
"You received this message because of your affiliation with the #{name} at #{url}.",
|
84
|
+
"If you do not want to receive this messages any more, you may <a href=\"{{{ pm:unsubscribe }}}\">Unsubscribe from this list</a>.",
|
85
|
+
"Please understand that unsubscribing means you will no longer receive mandatory messages and announcements."
|
86
|
+
].join(" ")
|
87
|
+
|
88
|
+
# Attach unsubscribe link
|
89
|
+
rendered[:body] = "#{rendered[:body]}\r\n\r\n<hr><small>#{unsubscribe}</small>"
|
90
|
+
|
91
|
+
rendered
|
92
|
+
end
|
93
|
+
|
69
94
|
def mailer_settings
|
70
95
|
EffectiveMessaging
|
71
96
|
end
|