messaging_client 0.1.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/helpers/sns_helper.rb +6 -2
- data/app/models/messaging/message.rb +1 -1
- data/app/models/messaging/notify_me.rb +1 -1
- data/lib/messaging/client.rb +13 -21
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62c9c566908c290110e41c455e63a5650dad343d733674dae90c203787bb2608
|
4
|
+
data.tar.gz: 1583cb8c8a557b213ae6762f45d2c775ed1dfb915a08e0881dd99232c12f45fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f32df0c7bf46c68a01fedfd8f0be70d4a6a259138ff9f0dd99f3f00e4e118ea5286acf07535a9ec46c39a5f150e0c86c20e0a19fac7c6626cf73c42952c557
|
7
|
+
data.tar.gz: 93f53d8b2f163fe32f52c765fea8e616482f88d9c1198b649dabd337efaad9719c44bc1e46f3e12e6e100583067e9ccd36336b91dcacd52b0ec2c4383fcaeda3
|
data/app/helpers/sns_helper.rb
CHANGED
@@ -22,7 +22,11 @@ module SnsHelper
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def sns_data
|
25
|
-
@sns_data ||= ActiveSupport::JSON.decode(
|
25
|
+
@sns_data ||= ActiveSupport::JSON.decode(raw_data).symbolize_keys!
|
26
|
+
end
|
27
|
+
|
28
|
+
def raw_data
|
29
|
+
request.body.respond_to?(:string) ? request.body.string : request.body
|
26
30
|
end
|
27
31
|
|
28
32
|
def sns_message_id
|
@@ -36,4 +40,4 @@ module SnsHelper
|
|
36
40
|
def sns_duplicate_submission?
|
37
41
|
Rails.cache.read(sns_message_id)
|
38
42
|
end
|
39
|
-
end
|
43
|
+
end
|
data/lib/messaging/client.rb
CHANGED
@@ -3,29 +3,10 @@ require 'aws-sdk-sns'
|
|
3
3
|
module Messaging
|
4
4
|
class Client
|
5
5
|
|
6
|
-
# @param key_name [String]
|
7
|
-
# @param url [String]
|
8
|
-
# @param secret_key [String]
|
9
|
-
def self.subscribe_to(key_name,url,secret_key="")
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
# @param key_name [String]
|
14
|
-
def self.unsubscribe_from(key_name)
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
6
|
# @param key [String]
|
19
7
|
# @param data [Hash]
|
20
8
|
def self.post_message(key,data={})
|
21
|
-
|
22
|
-
publish_to_sns(key,data)
|
23
|
-
rescue
|
24
|
-
# on transition ignore errors.
|
25
|
-
end
|
26
|
-
|
27
|
-
m = Message.new(key_name: key, data: data.to_json)
|
28
|
-
m.create
|
9
|
+
publish_to_sns(key,data)
|
29
10
|
end
|
30
11
|
|
31
12
|
def self.publish_to_sns(key,data)
|
@@ -36,7 +17,18 @@ module Messaging
|
|
36
17
|
)
|
37
18
|
topic_arn = sns.topics.select{|t| t.arn.match(/([^:]*)$/)[0] == key.to_s }.first.try(:arn)
|
38
19
|
topic = sns.topic(topic_arn)
|
39
|
-
|
20
|
+
|
21
|
+
msg = { message: data.to_json }
|
22
|
+
if data['account_name']
|
23
|
+
msg[:message_attributes] = {
|
24
|
+
account_name: {
|
25
|
+
data_type: 'String',
|
26
|
+
string_value: data['account_name']
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
topic.publish(msg)
|
40
32
|
end
|
41
33
|
|
42
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dwayne Macgowan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
homepage: ''
|
70
70
|
licenses: []
|
71
71
|
metadata: {}
|
72
|
-
post_install_message:
|
72
|
+
post_install_message:
|
73
73
|
rdoc_options: []
|
74
74
|
require_paths:
|
75
75
|
- lib
|
@@ -84,9 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
87
|
+
rubygems_version: 3.0.1
|
88
|
+
signing_key:
|
90
89
|
specification_version: 4
|
91
90
|
summary: Client library for padma-messaging-ws
|
92
91
|
test_files: []
|