toot 0.2.0 → 0.3.0
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/README.md +7 -3
- data/lib/toot/calls_event_callback.rb +8 -0
- data/lib/toot/calls_handlers.rb +4 -0
- data/lib/toot/publishes_event.rb +4 -0
- data/lib/toot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9b0c0822e633371fcbbdc2ba92d31a364881171
|
4
|
+
data.tar.gz: 186183478e3ae5c8b06c07fb3e04174e38618d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d0a18cec34529905e071f44662e72e48239aeec4165b8ccc797347e103f3dfed1698d2007fc090462dc9fc278c58391eb282db3114ce0a7bd534662585c80a0
|
7
|
+
data.tar.gz: aff2653ab9df7ad42dae792eb617e944b2a5793af2e0fb82c0fd7257491770fc78510bf13fc63dca5f344268be42208a3c4c63f45b04bc3638898556815f9a00
|
data/README.md
CHANGED
@@ -162,9 +162,12 @@ routing config][2], or more generically, you can just decorate the
|
|
162
162
|
service with another callable object that does the authentication
|
163
163
|
checks.
|
164
164
|
|
165
|
-
|
166
|
-
|
167
|
-
|
165
|
+
To add authentication to outgoing requests you can build a Faraday
|
166
|
+
middleware and install it to the default connection using the
|
167
|
+
`http_connection` configuration option.
|
168
|
+
|
169
|
+
Check out the [toot-auth][3] for an example implementation using HTTP
|
170
|
+
Basic auth and credentials stored in Redis.
|
168
171
|
|
169
172
|
## Installation
|
170
173
|
|
@@ -205,3 +208,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/waterm
|
|
205
208
|
|
206
209
|
[1]: https://en.wikipedia.org/wiki/Reverse_domain_name_notation
|
207
210
|
[2]: http://guides.rubyonrails.org/routing.html#advanced-constraints
|
211
|
+
[3]: https://github.com/watermarkchurch/toot-auth
|
@@ -7,19 +7,27 @@ module Toot
|
|
7
7
|
def perform(callback_url, event_data)
|
8
8
|
uri = URI(callback_url)
|
9
9
|
|
10
|
+
logger.info { "Event ID: #{event_data["id"]}" }
|
11
|
+
logger.info { "URL: #{callback_url}" }
|
12
|
+
logger.debug { "Payload: #{event_data.inspect}" }
|
13
|
+
|
10
14
|
response = Toot.config.http_connection.post do |request|
|
11
15
|
request.url uri
|
12
16
|
request.body = event_data.to_json
|
13
17
|
request.headers["Content-Type"] = "application/json"
|
14
18
|
end
|
15
19
|
|
20
|
+
logger.debug { "Response from callback service: #{response.inspect}" }
|
21
|
+
|
16
22
|
if response.success?
|
17
23
|
if response.headers["X-Toot-Unsubscribe"]
|
24
|
+
logger.info { "Service requested unsubscribe via X-Toot-Unsubscribe header. Unsubscribing." }
|
18
25
|
Toot.redis do |r|
|
19
26
|
r.srem event_data["channel"], callback_url
|
20
27
|
end
|
21
28
|
end
|
22
29
|
else
|
30
|
+
logger.error { "Error response: #{response.inspect}" }
|
23
31
|
raise CallbackFailure, "Response code: #{response.status}"
|
24
32
|
end
|
25
33
|
end
|
data/lib/toot/calls_handlers.rb
CHANGED
@@ -4,6 +4,10 @@ module Toot
|
|
4
4
|
|
5
5
|
def perform(event_data)
|
6
6
|
event = Event.new(event_data)
|
7
|
+
|
8
|
+
logger.info { "Event ID: #{event_data["id"]}" }
|
9
|
+
logger.debug { "Payload: #{event_data.inspect}" }
|
10
|
+
|
7
11
|
Toot.config
|
8
12
|
.subscriptions_for_channel(event.channel)
|
9
13
|
.each { |s| s.handler.call(event) }
|
data/lib/toot/publishes_event.rb
CHANGED
@@ -4,6 +4,10 @@ module Toot
|
|
4
4
|
|
5
5
|
def perform(event_data)
|
6
6
|
event = Event.new(event_data)
|
7
|
+
|
8
|
+
logger.info { "Event ID: #{event.id}" }
|
9
|
+
logger.debug { "Payload: #{event.inspect}" }
|
10
|
+
|
7
11
|
channel_callback_urls(event.channel)
|
8
12
|
.map { |callback| CallsEventCallback.perform_async(callback, event_data) }
|
9
13
|
end
|
data/lib/toot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Petticrew
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|