messaging_client 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/sns_helper.rb +39 -0
- data/lib/messaging/client.rb +5 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dadb5c678a9fdb5f0e6b223e34e401c95332dc0a
|
4
|
+
data.tar.gz: ae6421553882c82c2aa547952b55f2e5a42cb556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafa32f1bed397b24a00c767130872cffa7cb818f10302b0c3b7cf35d276b876bf4d763e1a32e74b12db3ee5f1c788da9cb19c9e20f7af03b2a07c883c406748
|
7
|
+
data.tar.gz: 14142c1e17000bc145b8dd6639172535f01b0ed8ff7017fb11a25f996bdfc4b106b591d897f1d54a8a8d5b1695c62da6495331860f3404f1949a16206b9b61fa
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SnsHelper
|
2
|
+
def sns_verified?
|
3
|
+
# TODO https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.verify.signature.html
|
4
|
+
return true
|
5
|
+
end
|
6
|
+
|
7
|
+
def sns_message
|
8
|
+
@sns_message ||= ActiveSupport::JSON.decode(sns_data[:Message]).symbolize_keys!
|
9
|
+
end
|
10
|
+
|
11
|
+
# topic, without all the ARN
|
12
|
+
def sns_topic
|
13
|
+
sns_data[:TopicArn].match(/([^:]*)$/)[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def sns_type
|
17
|
+
request.headers['x-amz-sns-message-type']
|
18
|
+
end
|
19
|
+
|
20
|
+
def sns_notification_id
|
21
|
+
request.headers['x-amz-sns-message-id']
|
22
|
+
end
|
23
|
+
|
24
|
+
def sns_data
|
25
|
+
@sns_data ||= ActiveSupport::JSON.decode(request.body).symbolize_keys!
|
26
|
+
end
|
27
|
+
|
28
|
+
def sns_message_id
|
29
|
+
sns_data[:MessageId]
|
30
|
+
end
|
31
|
+
|
32
|
+
def sns_set_as_received!
|
33
|
+
Rails.cache.write(sns_message_id, true, expires_in: 2.minutes)
|
34
|
+
end
|
35
|
+
|
36
|
+
def sns_duplicate_submission?
|
37
|
+
Rails.cache.read(sns_message_id)
|
38
|
+
end
|
39
|
+
end
|
data/lib/messaging/client.rb
CHANGED
@@ -18,7 +18,11 @@ module Messaging
|
|
18
18
|
# @param key [String]
|
19
19
|
# @param data [Hash]
|
20
20
|
def self.post_message(key,data={})
|
21
|
-
|
21
|
+
begin
|
22
|
+
publish_to_sns(key,data)
|
23
|
+
rescue
|
24
|
+
# on transition ignore errors.
|
25
|
+
end
|
22
26
|
|
23
27
|
m = Message.new(key_name: key, data: data.to_json)
|
24
28
|
m.create
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messaging_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dwayne Macgowan
|
@@ -59,6 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- app/helpers/sns_helper.rb
|
62
63
|
- app/models/messaging/message.rb
|
63
64
|
- app/models/messaging/notify_me.rb
|
64
65
|
- config/initializers/messaging_client.rb
|