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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1061a51a0950e3c322de72f007ce0380e2b9fa6d0089d85bbd905b1cad9a8acd
4
- data.tar.gz: 5f1dcb71f399a6d94fb49ba3284bbec7f007c6f8f7494e05aa1bf8f4cde618cf
3
+ metadata.gz: 03bcd735271fc2657ea29f9c59b80324d5f869b03b289cdbf3b636204a4c956a
4
+ data.tar.gz: a6926fb92f8c972c9845489c303d341afbad242e2257b22a6ea061235c1008aa
5
5
  SHA512:
6
- metadata.gz: e4facce29949bb6bfd8a56fcea0029c09da098da22aedcef8c018209c3091e87fcc8a53123cf56ea26b99735cb0d83119a135930428d672129125f3459e0debe
7
- data.tar.gz: d97ffe863b7cb1d14829f49ddf012723d79a99b3c1b2038dbd48e99bf8caf1193388ff8fcd5813dad9b25168d9118d3c3abae5d790126d10ba916e6cb66fa278
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
- headers.merge!(message_stream: 'broadcast-stream') if defined?(Postmark)
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
- headers.merge!(message_stream: 'broadcast-stream') if defined?(Postmark)
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveMessaging
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.5.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect