effective_messaging 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
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
|
@@ -224,6 +224,14 @@ module Effective
|
|
224
224
|
report.collection().select { |resource| notifiable_tomorrow?(resource) }.count if report
|
225
225
|
end
|
226
226
|
|
227
|
+
def enable!
|
228
|
+
update!(enabled: true)
|
229
|
+
end
|
230
|
+
|
231
|
+
def disable!
|
232
|
+
update!(enabled: false)
|
233
|
+
end
|
234
|
+
|
227
235
|
# Enqueues this notification to send right away.
|
228
236
|
# Only applies to scheduled_email? notifications
|
229
237
|
def send_now!
|
data/config/routes.rb
CHANGED
@@ -15,6 +15,9 @@ EffectiveMessaging::Engine.routes.draw do
|
|
15
15
|
resources :chat_messages, only: [:index, :show, :destroy]
|
16
16
|
|
17
17
|
resources :notifications do
|
18
|
+
post :enable, on: :member
|
19
|
+
post :disable, on: :member
|
20
|
+
|
18
21
|
post :send_now, on: :member
|
19
22
|
post :skip_once, on: :member
|
20
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|