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 +4 -4
- data/lib/webhook_system/job.rb +10 -3
- data/lib/webhook_system/subscription.rb +9 -0
- data/lib/webhook_system/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 428ebdafe157c314eb2426f47c9a04ab236dc6261b7ab469ddbbee5ff86fdf87
|
4
|
+
data.tar.gz: 22dc65660838f49875cdefb303e7ef783e97e53931c9ad889e20a3954bb22000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da4e60ad66ac25c63eff52f51f8e46f3fc0a1087b9f4ff5e355290cefe3d6003853666cf3a92db84f2dcd1f1ec3efb47d559d31819afb16548b14223e2b58b66
|
7
|
+
data.tar.gz: f4ace79d2aa3f3b63492f7220f27f03a7dc5af3b49e503197b6f98f9ac8648ea28ac08d2e794c521fc80910391ddb77cc3baea275d33b41ac1e17ac45f35469c
|
data/lib/webhook_system/job.rb
CHANGED
@@ -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
|
50
|
+
ensure_success(response, :POST, subscription)
|
51
51
|
end
|
52
52
|
|
53
|
-
def self.ensure_success(response, http_method,
|
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
|
-
|
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
|
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.
|
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-
|
12
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|