webhook_system 2.1.5 → 2.1.6

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: 341113a9e842aad6e6425cd7674c14d3122adde0316dd95663e5397d93459446
4
- data.tar.gz: d07b90ac598e7a5a929248f649f6a5bcd4a2465c0b81a34c3ecc56acee6cb6bd
3
+ metadata.gz: 428ebdafe157c314eb2426f47c9a04ab236dc6261b7ab469ddbbee5ff86fdf87
4
+ data.tar.gz: 22dc65660838f49875cdefb303e7ef783e97e53931c9ad889e20a3954bb22000
5
5
  SHA512:
6
- metadata.gz: bfc631f53dfbc28294c5d5f25ffc54ba3214c8b52f75a69a375dc1ab138b9f1afa8e0676177177ecf9f79aa8253565e093d9db48f5ac61d7fc4ed687c4a5322c
7
- data.tar.gz: 5500acb854e2dee0a695b00354e1bc244861731885f63dea849d4a39d7cb9a53755a22a82af35c47b4b2fe759ad901248f30e023b73fad618e3980d126e8c0fe
6
+ metadata.gz: da4e60ad66ac25c63eff52f51f8e46f3fc0a1087b9f4ff5e355290cefe3d6003853666cf3a92db84f2dcd1f1ec3efb47d559d31819afb16548b14223e2b58b66
7
+ data.tar.gz: f4ace79d2aa3f3b63492f7220f27f03a7dc5af3b49e503197b6f98f9ac8648ea28ac08d2e794c521fc80910391ddb77cc3baea275d33b41ac1e17ac45f35469c
@@ -47,13 +47,20 @@ module WebhookSystem
47
47
  end
48
48
 
49
49
  log_response(subscription, event, request, response)
50
- ensure_success(response, :POST, subscription.url)
50
+ ensure_success(response, :POST, subscription)
51
51
  end
52
52
 
53
- def self.ensure_success(response, http_method, url)
53
+ def self.ensure_success(response, http_method, subscription)
54
+ url = subscription.url
54
55
  status = response.status
55
56
  unless (200..299).cover? status
56
- text = "#{http_method} request to #{url} failed with code: #{status} and error #{response.body}"
57
+ if subscription.respond_to?(:account_id)
58
+ account_info = subscription.account_info
59
+ inner = "failed for account #{account_info} with"
60
+ else
61
+ inner = "failed with"
62
+ end
63
+ text = "#{http_method} request to #{url} #{inner} code: #{status} and error #{response.body}"
57
64
  raise RequestFailed.new(text, status, response.body)
58
65
  end
59
66
  end
@@ -4,6 +4,8 @@ module WebhookSystem
4
4
  class Subscription < ActiveRecord::Base
5
5
  self.table_name = 'webhook_subscriptions'
6
6
 
7
+ belongs_to :account if defined?(Account)
8
+
7
9
  validates :url, presence: true, url: { no_local: true }
8
10
  validates :secret, presence: true
9
11
 
@@ -59,5 +61,12 @@ module WebhookSystem
59
61
  self.topics_attributes = new_topics_attributes
60
62
  end
61
63
 
64
+ def account_info
65
+ if defined?(Account)
66
+ "#{account_id}:#{account.try(:name)}"
67
+ else
68
+ account_id.to_s
69
+ end
70
+ end
62
71
  end
63
72
  end
@@ -1,3 +1,3 @@
1
1
  module WebhookSystem
2
- VERSION = '2.1.5'
2
+ VERSION = '2.1.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webhook_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Banasik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-07-24 00:00:00.000000000 Z
12
+ date: 2019-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport