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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 083d9404092e22b97c3cc28414d2a7544f00e4af
4
- data.tar.gz: a384f7ab9ebc684a9374b2d6b24f4f1844717322
3
+ metadata.gz: b9b0c0822e633371fcbbdc2ba92d31a364881171
4
+ data.tar.gz: 186183478e3ae5c8b06c07fb3e04174e38618d29
5
5
  SHA512:
6
- metadata.gz: fc56a2166877aad3957fa83a7a24342bac4191ab05df5b3d73fb409bb6e92740ff0592606cfa66a23741cba03bcc2f8163bddd5c4ec43bb1158a3fd454606201
7
- data.tar.gz: 945bc0a83d6b9e0fc831346b835a2157fc21fbff6c0413a1df648853009bfff7cfb46fcb3245eddf9f68814759aae51fd63b16663ced58fd999064b81008ef45
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
- **TODO:** Currently we don't have the ability to add credentials to
166
- outgoing requests. This will need to be added before this problem is
167
- 100% solved.
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
@@ -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) }
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Toot
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-09 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq