webhook_system 2.1.4 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +53 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +40 -1
- data/gemfiles/{rails_4.gemfile → rails_4.2.gemfile} +0 -2
- data/gemfiles/rails_4.2.gemfile.lock +265 -0
- data/gemfiles/{rails_5.gemfile → rails_5.0.gemfile} +1 -3
- data/gemfiles/rails_5.1.gemfile +6 -0
- data/gemfiles/rails_5_2.gemfile +1 -3
- data/gemfiles/rails_6.0.gemfile +6 -0
- data/gemfiles/rails_6.1.gemfile +6 -0
- data/lib/webhook_system/base_event.rb +4 -0
- data/lib/webhook_system/job.rb +30 -5
- data/lib/webhook_system/subscription.rb +16 -2
- data/lib/webhook_system/version.rb +1 -1
- data/webhook_system.gemspec +7 -8
- metadata +50 -37
- data/.travis.yml +0 -22
- data/Appraisals +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95a60a1976fb1383405d2f91b97ac05e8d2d771d4df832587a54847ad2bb9bdf
|
4
|
+
data.tar.gz: f253442be94bbf08263d5642b211de58653bf0b0ac29e4d1a67dc46bf9712cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca145b2131eeef0ee2049f3988838fce583950cc960cb973ddaa975338c1f8488e2fc2d30e79b91f8a154898c712b00744f7958ab84765cdd0bf17604021000
|
7
|
+
data.tar.gz: 7c0d87b9026185c5d59f26fdd16ae0317ffd2b72756e0f996c43cd2c0858c12d96d3d05099dc7af6730897a4eb63b4b144c034078a1f673ef2315129ba3253a7
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: build
|
9
|
+
|
10
|
+
on: [push, pull_request]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-20.04
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
ruby:
|
19
|
+
- 2.6
|
20
|
+
- 2.5
|
21
|
+
gemfile:
|
22
|
+
- rails_4.2
|
23
|
+
- rails_5.0
|
24
|
+
- rails_5.1
|
25
|
+
- rails_5_2
|
26
|
+
- rails_6.0
|
27
|
+
# expected WebhookSystem::Job::RequestFailed with "POST request to http://lvh.me/hook1 failed with code: 400 and error I don't like you", got #<NameError: uninitialized constant ActiveSupport::Testing::Assertions::Minitest> with backtrace:
|
28
|
+
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/assertions.rb:36:in `rescue in assert_nothing_raised'
|
29
|
+
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/assertions.rb:33:in `assert_nothing_raised'
|
30
|
+
# - rails_6.1
|
31
|
+
exclude:
|
32
|
+
- gemfile: rails_4.2
|
33
|
+
ruby: 2.7
|
34
|
+
- gemfile: rails_4.2
|
35
|
+
ruby: 3.0
|
36
|
+
- gemfile: rails_5.0
|
37
|
+
ruby: 2.7
|
38
|
+
- gemfile: rails_5.0
|
39
|
+
ruby: 3.0
|
40
|
+
- gemfile: rails_5.1
|
41
|
+
ruby: 2.7
|
42
|
+
- gemfile: rails_5.1
|
43
|
+
ruby: 3.0
|
44
|
+
|
45
|
+
env:
|
46
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@v2
|
49
|
+
- uses: ruby/setup-ruby@v1
|
50
|
+
with:
|
51
|
+
ruby-version: ${{ matrix.ruby }}
|
52
|
+
bundler-cache: true
|
53
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,47 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v2.3.0](https://github.com/payrollhero/webhook_system/tree/v2.3.0) (2021-08-xx)
|
4
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.2.0...v2.3.0)
|
5
|
+
|
6
|
+
* Add ability to launch inline jobs instead of making external HTTP calls to another service.
|
7
|
+
|
8
|
+
## [v2.2.0](https://github.com/payrollhero/webhook_system/tree/v2.2.0) (2019-11-07)
|
9
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.6...v2.2.0)
|
10
|
+
|
11
|
+
* Syntatic sugar: simple dispatch call to also build the event object
|
12
|
+
|
13
|
+
## [v2.1.6](https://github.com/payrollhero/webhook_system/tree/v2.1.6) (2019-07-26)
|
14
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.5...v2.1.6)
|
15
|
+
|
16
|
+
* add account info to error message
|
17
|
+
|
18
|
+
## [v2.1.5](https://github.com/payrollhero/webhook_system/tree/v2.1.5) (2019-07-24)
|
19
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.4...v2.1.5)
|
20
|
+
|
21
|
+
* response body error message in exception
|
22
|
+
|
23
|
+
## [v2.1.4](https://github.com/payrollhero/webhook_system/tree/v2.1.4) (2019-05-10)
|
24
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.3...v2.1.4)
|
25
|
+
|
26
|
+
* Make URL display in Exception message
|
27
|
+
* Make tests pass again
|
28
|
+
* Small typo fix by Heath Attig, thank you
|
29
|
+
|
30
|
+
## [v2.1.3](https://github.com/payrollhero/webhook_system/tree/v2.1.3) (2017-12-06)
|
31
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.2...v2.1.3)
|
32
|
+
|
33
|
+
by Ron
|
34
|
+
|
35
|
+
## [v2.1.2](https://github.com/payrollhero/webhook_system/tree/v2.1.2) (2017-01-24)
|
36
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.1...v2.1.2)
|
37
|
+
|
38
|
+
by Piotr
|
39
|
+
|
3
40
|
## [v2.1.1](https://github.com/payrollhero/webhook_system/tree/v2.1.1) (2016-12-20)
|
4
41
|
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.1.0...v2.1.1)
|
5
42
|
|
43
|
+
by Piotr
|
44
|
+
|
6
45
|
## [v2.1.0](https://github.com/payrollhero/webhook_system/tree/v2.1.0) (2016-07-20)
|
7
46
|
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v2.0.0...v2.1.0)
|
8
47
|
|
@@ -53,4 +92,4 @@
|
|
53
92
|
|
54
93
|
|
55
94
|
|
56
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
95
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
@@ -0,0 +1,265 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
webhook_system (2.3.0)
|
5
|
+
activejob (> 4.2, < 6.1)
|
6
|
+
activerecord (> 4.2, < 6.1)
|
7
|
+
activesupport (> 4.2, < 6.1)
|
8
|
+
faraday (> 0.9)
|
9
|
+
faraday-encoding (>= 0.0.2, < 1.0)
|
10
|
+
ph_model
|
11
|
+
validate_url (~> 1.0)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
actionmailer (4.2.11.3)
|
17
|
+
actionpack (= 4.2.11.3)
|
18
|
+
actionview (= 4.2.11.3)
|
19
|
+
activejob (= 4.2.11.3)
|
20
|
+
mail (~> 2.5, >= 2.5.4)
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
actionpack (4.2.11.3)
|
23
|
+
actionview (= 4.2.11.3)
|
24
|
+
activesupport (= 4.2.11.3)
|
25
|
+
rack (~> 1.6)
|
26
|
+
rack-test (~> 0.6.2)
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
29
|
+
actionview (4.2.11.3)
|
30
|
+
activesupport (= 4.2.11.3)
|
31
|
+
builder (~> 3.1)
|
32
|
+
erubis (~> 2.7.0)
|
33
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
35
|
+
active_attr (0.15.3)
|
36
|
+
actionpack (>= 3.0.2, < 7.0)
|
37
|
+
activemodel (>= 3.0.2, < 7.0)
|
38
|
+
activesupport (>= 3.0.2, < 7.0)
|
39
|
+
activejob (4.2.11.3)
|
40
|
+
activesupport (= 4.2.11.3)
|
41
|
+
globalid (>= 0.3.0)
|
42
|
+
activemodel (4.2.11.3)
|
43
|
+
activesupport (= 4.2.11.3)
|
44
|
+
builder (~> 3.1)
|
45
|
+
activerecord (4.2.11.3)
|
46
|
+
activemodel (= 4.2.11.3)
|
47
|
+
activesupport (= 4.2.11.3)
|
48
|
+
arel (~> 6.0)
|
49
|
+
activesupport (4.2.11.3)
|
50
|
+
i18n (~> 0.7)
|
51
|
+
minitest (~> 5.1)
|
52
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
53
|
+
tzinfo (~> 1.1)
|
54
|
+
addressable (2.8.0)
|
55
|
+
public_suffix (>= 2.0.2, < 5.0)
|
56
|
+
arel (6.0.4)
|
57
|
+
ast (2.4.2)
|
58
|
+
async (1.30.1)
|
59
|
+
console (~> 1.10)
|
60
|
+
nio4r (~> 2.3)
|
61
|
+
timers (~> 4.1)
|
62
|
+
async-http (0.56.5)
|
63
|
+
async (>= 1.25)
|
64
|
+
async-io (>= 1.28)
|
65
|
+
async-pool (>= 0.2)
|
66
|
+
protocol-http (~> 0.22.0)
|
67
|
+
protocol-http1 (~> 0.14.0)
|
68
|
+
protocol-http2 (~> 0.14.0)
|
69
|
+
async-http-faraday (0.11.0)
|
70
|
+
async-http (~> 0.42)
|
71
|
+
faraday
|
72
|
+
async-io (1.32.2)
|
73
|
+
async
|
74
|
+
async-pool (0.3.8)
|
75
|
+
async (>= 1.25)
|
76
|
+
builder (3.2.4)
|
77
|
+
coderay (1.1.3)
|
78
|
+
concurrent-ruby (1.1.9)
|
79
|
+
console (1.13.1)
|
80
|
+
fiber-local
|
81
|
+
crack (0.4.5)
|
82
|
+
rexml
|
83
|
+
crass (1.0.6)
|
84
|
+
diff-lcs (1.4.4)
|
85
|
+
erubis (2.7.0)
|
86
|
+
factory_bot (5.2.0)
|
87
|
+
activesupport (>= 4.2.0)
|
88
|
+
faraday (1.7.0)
|
89
|
+
faraday-em_http (~> 1.0)
|
90
|
+
faraday-em_synchrony (~> 1.0)
|
91
|
+
faraday-excon (~> 1.1)
|
92
|
+
faraday-httpclient (~> 1.0.1)
|
93
|
+
faraday-net_http (~> 1.0)
|
94
|
+
faraday-net_http_persistent (~> 1.1)
|
95
|
+
faraday-patron (~> 1.0)
|
96
|
+
faraday-rack (~> 1.0)
|
97
|
+
multipart-post (>= 1.2, < 3)
|
98
|
+
ruby2_keywords (>= 0.0.4)
|
99
|
+
faraday-em_http (1.0.0)
|
100
|
+
faraday-em_synchrony (1.0.0)
|
101
|
+
faraday-encoding (0.0.5)
|
102
|
+
faraday
|
103
|
+
faraday-excon (1.1.0)
|
104
|
+
faraday-http-cache (2.2.0)
|
105
|
+
faraday (>= 0.8)
|
106
|
+
faraday-httpclient (1.0.1)
|
107
|
+
faraday-net_http (1.0.1)
|
108
|
+
faraday-net_http_persistent (1.2.0)
|
109
|
+
faraday-patron (1.0.0)
|
110
|
+
faraday-rack (1.0.0)
|
111
|
+
fiber-local (1.0.0)
|
112
|
+
github_changelog_generator (1.16.4)
|
113
|
+
activesupport
|
114
|
+
async (>= 1.25.0)
|
115
|
+
async-http-faraday
|
116
|
+
faraday-http-cache
|
117
|
+
multi_json
|
118
|
+
octokit (~> 4.6)
|
119
|
+
rainbow (>= 2.2.1)
|
120
|
+
rake (>= 10.0)
|
121
|
+
globalid (0.4.2)
|
122
|
+
activesupport (>= 4.2.0)
|
123
|
+
hashdiff (1.0.1)
|
124
|
+
i18n (0.9.5)
|
125
|
+
concurrent-ruby (~> 1.0)
|
126
|
+
io-console (0.5.9)
|
127
|
+
irb (1.3.7)
|
128
|
+
reline (>= 0.2.7)
|
129
|
+
loofah (2.12.0)
|
130
|
+
crass (~> 1.0.2)
|
131
|
+
nokogiri (>= 1.5.9)
|
132
|
+
mail (2.7.1)
|
133
|
+
mini_mime (>= 0.1.1)
|
134
|
+
method_source (1.0.0)
|
135
|
+
mini_mime (1.1.0)
|
136
|
+
mini_portile2 (2.6.1)
|
137
|
+
minitest (5.14.4)
|
138
|
+
multi_json (1.15.0)
|
139
|
+
multipart-post (2.1.1)
|
140
|
+
nio4r (2.5.8)
|
141
|
+
nokogiri (1.12.3)
|
142
|
+
mini_portile2 (~> 2.6.1)
|
143
|
+
racc (~> 1.4)
|
144
|
+
octokit (4.21.0)
|
145
|
+
faraday (>= 0.9)
|
146
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
147
|
+
parser (2.7.2.0)
|
148
|
+
ast (~> 2.4.1)
|
149
|
+
ph_model (1.1.1)
|
150
|
+
active_attr (~> 0.8)
|
151
|
+
activemodel (> 3.2)
|
152
|
+
activesupport (> 3.2)
|
153
|
+
powerpack (0.1.3)
|
154
|
+
protocol-hpack (1.4.2)
|
155
|
+
protocol-http (0.22.5)
|
156
|
+
protocol-http1 (0.14.1)
|
157
|
+
protocol-http (~> 0.22)
|
158
|
+
protocol-http2 (0.14.2)
|
159
|
+
protocol-hpack (~> 1.4)
|
160
|
+
protocol-http (~> 0.18)
|
161
|
+
pry (0.14.1)
|
162
|
+
coderay (~> 1.1)
|
163
|
+
method_source (~> 1.0)
|
164
|
+
public_suffix (4.0.6)
|
165
|
+
racc (1.5.2)
|
166
|
+
rack (1.6.13)
|
167
|
+
rack-test (0.6.3)
|
168
|
+
rack (>= 1.0)
|
169
|
+
rails (4.2.11.3)
|
170
|
+
actionmailer (= 4.2.11.3)
|
171
|
+
actionpack (= 4.2.11.3)
|
172
|
+
actionview (= 4.2.11.3)
|
173
|
+
activejob (= 4.2.11.3)
|
174
|
+
activemodel (= 4.2.11.3)
|
175
|
+
activerecord (= 4.2.11.3)
|
176
|
+
activesupport (= 4.2.11.3)
|
177
|
+
bundler (>= 1.3.0, < 2.0)
|
178
|
+
railties (= 4.2.11.3)
|
179
|
+
sprockets-rails
|
180
|
+
rails-deprecated_sanitizer (1.0.4)
|
181
|
+
activesupport (>= 4.2.0.alpha)
|
182
|
+
rails-dom-testing (1.0.9)
|
183
|
+
activesupport (>= 4.2.0, < 5.0)
|
184
|
+
nokogiri (~> 1.6)
|
185
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
186
|
+
rails-html-sanitizer (1.3.0)
|
187
|
+
loofah (~> 2.3)
|
188
|
+
railties (4.2.11.3)
|
189
|
+
actionpack (= 4.2.11.3)
|
190
|
+
activesupport (= 4.2.11.3)
|
191
|
+
rake (>= 0.8.7)
|
192
|
+
thor (>= 0.18.1, < 2.0)
|
193
|
+
rainbow (2.2.2)
|
194
|
+
rake
|
195
|
+
rake (13.0.6)
|
196
|
+
reline (0.2.7)
|
197
|
+
io-console (~> 0.5)
|
198
|
+
rexml (3.2.5)
|
199
|
+
rspec (3.10.0)
|
200
|
+
rspec-core (~> 3.10.0)
|
201
|
+
rspec-expectations (~> 3.10.0)
|
202
|
+
rspec-mocks (~> 3.10.0)
|
203
|
+
rspec-core (3.10.1)
|
204
|
+
rspec-support (~> 3.10.0)
|
205
|
+
rspec-expectations (3.10.1)
|
206
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
207
|
+
rspec-support (~> 3.10.0)
|
208
|
+
rspec-mocks (3.10.2)
|
209
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
210
|
+
rspec-support (~> 3.10.0)
|
211
|
+
rspec-support (3.10.2)
|
212
|
+
rubocop (0.48.1)
|
213
|
+
parser (>= 2.3.3.1, < 3.0)
|
214
|
+
powerpack (~> 0.1)
|
215
|
+
rainbow (>= 1.99.1, < 3.0)
|
216
|
+
ruby-progressbar (~> 1.7)
|
217
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
218
|
+
ruby-progressbar (1.11.0)
|
219
|
+
ruby2_keywords (0.0.5)
|
220
|
+
rubygems-tasks (0.2.5)
|
221
|
+
irb (~> 1.0)
|
222
|
+
sawyer (0.8.2)
|
223
|
+
addressable (>= 2.3.5)
|
224
|
+
faraday (> 0.8, < 2.0)
|
225
|
+
sprockets (4.0.2)
|
226
|
+
concurrent-ruby (~> 1.0)
|
227
|
+
rack (> 1, < 3)
|
228
|
+
sprockets-rails (3.2.2)
|
229
|
+
actionpack (>= 4.0)
|
230
|
+
activesupport (>= 4.0)
|
231
|
+
sprockets (>= 3.0.0)
|
232
|
+
sqlite3 (1.3.13)
|
233
|
+
thor (1.1.0)
|
234
|
+
thread_safe (0.3.6)
|
235
|
+
timers (4.3.3)
|
236
|
+
tzinfo (1.2.9)
|
237
|
+
thread_safe (~> 0.1)
|
238
|
+
unicode-display_width (1.7.0)
|
239
|
+
validate_url (1.0.13)
|
240
|
+
activemodel (>= 3.0.0)
|
241
|
+
public_suffix
|
242
|
+
webmock (3.14.0)
|
243
|
+
addressable (>= 2.8.0)
|
244
|
+
crack (>= 0.3.2)
|
245
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
246
|
+
|
247
|
+
PLATFORMS
|
248
|
+
ruby
|
249
|
+
|
250
|
+
DEPENDENCIES
|
251
|
+
bundler (> 1.17, < 2.5)
|
252
|
+
factory_bot
|
253
|
+
github_changelog_generator (~> 1.6)
|
254
|
+
pry
|
255
|
+
rails (~> 4.2.11)
|
256
|
+
rake
|
257
|
+
rspec (~> 3.0)
|
258
|
+
rubocop (~> 0.48.1)
|
259
|
+
rubygems-tasks (~> 0.2)
|
260
|
+
sqlite3 (~> 1.3.6)
|
261
|
+
webhook_system!
|
262
|
+
webmock
|
263
|
+
|
264
|
+
BUNDLED WITH
|
265
|
+
1.17.3
|
data/gemfiles/rails_5_2.gemfile
CHANGED
data/lib/webhook_system/job.rb
CHANGED
@@ -5,9 +5,10 @@ module WebhookSystem
|
|
5
5
|
|
6
6
|
# Exception class around non 200 responses
|
7
7
|
class RequestFailed < RuntimeError
|
8
|
-
def initialize(message, code)
|
8
|
+
def initialize(message, code, error_message=nil)
|
9
9
|
super(message)
|
10
10
|
@code = code
|
11
|
+
@error_message = error_message
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -31,7 +32,22 @@ module WebhookSystem
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def perform(subscription, event)
|
34
|
-
|
35
|
+
if subscription.url.match?(/^https?:/)
|
36
|
+
self.class.post(subscription, event)
|
37
|
+
elsif (match_data = subscription.url.match(/^inline:(.*)/)).present?
|
38
|
+
self.class.call_inline(match_data[1], subscription, event)
|
39
|
+
else
|
40
|
+
raise RuntimeError, "unknown prefix url for subscription"
|
41
|
+
ensure_success(ErrorResponse.new(exception), :INVALID, subscription)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.call_inline(job_name, subscription, event)
|
46
|
+
# subscription url could contain a job name, or a ruby class/method call
|
47
|
+
# how do we sanitize this not to be allowing hackers to call arbitrary code via
|
48
|
+
# a subscription? maybe a prefix is enough?
|
49
|
+
job_class = const_get("WebhookSystem::Inline#{job_name}Job")
|
50
|
+
job_class.perform_now(subscription, event)
|
35
51
|
end
|
36
52
|
|
37
53
|
def self.post(subscription, event)
|
@@ -46,12 +62,21 @@ module WebhookSystem
|
|
46
62
|
end
|
47
63
|
|
48
64
|
log_response(subscription, event, request, response)
|
49
|
-
ensure_success(response
|
65
|
+
ensure_success(response, :POST, subscription)
|
50
66
|
end
|
51
67
|
|
52
|
-
def self.ensure_success(
|
68
|
+
def self.ensure_success(response, http_method, subscription)
|
69
|
+
url = subscription.url
|
70
|
+
status = response.status
|
53
71
|
unless (200..299).cover? status
|
54
|
-
|
72
|
+
if subscription.respond_to?(:account_id)
|
73
|
+
account_info = subscription.account_info
|
74
|
+
inner = "failed for account #{account_info} with"
|
75
|
+
else
|
76
|
+
inner = "failed with"
|
77
|
+
end
|
78
|
+
text = "#{http_method} request to #{url} #{inner} code: #{status} and error #{response.body}"
|
79
|
+
raise RequestFailed.new(text, status, response.body)
|
55
80
|
end
|
56
81
|
end
|
57
82
|
|
@@ -4,7 +4,10 @@ module WebhookSystem
|
|
4
4
|
class Subscription < ActiveRecord::Base
|
5
5
|
self.table_name = 'webhook_subscriptions'
|
6
6
|
|
7
|
-
|
7
|
+
belongs_to :account if defined?(Account)
|
8
|
+
|
9
|
+
INLINE_JOB_REGEXP=/^inline:(.*)/
|
10
|
+
validates :url, presence: true, url: { no_local: true }, if: Proc.new { |a| !a.url.match?(INLINE_JOB_REGEXP) }
|
8
11
|
validates :secret, presence: true
|
9
12
|
|
10
13
|
has_many :topics, class_name: 'WebhookSystem::SubscriptionTopic', dependent: :destroy
|
@@ -31,7 +34,11 @@ module WebhookSystem
|
|
31
34
|
|
32
35
|
# Just a helper to get a nice representation of the subscription
|
33
36
|
def url_domain
|
34
|
-
|
37
|
+
if data = url.match(INLINE_JOB_REGEXP)
|
38
|
+
data[1]
|
39
|
+
else
|
40
|
+
URI.parse(url).host
|
41
|
+
end
|
35
42
|
end
|
36
43
|
|
37
44
|
# Abstraction around the topics relation, returns an array of the subscribed topic names
|
@@ -59,5 +66,12 @@ module WebhookSystem
|
|
59
66
|
self.topics_attributes = new_topics_attributes
|
60
67
|
end
|
61
68
|
|
69
|
+
def account_info
|
70
|
+
if defined?(Account)
|
71
|
+
"#{account_id}:#{account.try(:name)}"
|
72
|
+
else
|
73
|
+
account_id.to_s
|
74
|
+
end
|
75
|
+
end
|
62
76
|
end
|
63
77
|
end
|
data/webhook_system.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.name = 'webhook_system'
|
7
7
|
gem.version = WebhookSystem::VERSION
|
8
8
|
gem.authors = ['Piotr Banasik', 'Mykola Kyryk']
|
9
|
-
gem.email = '
|
9
|
+
gem.email = 'dev@payrollhero.com'
|
10
10
|
|
11
11
|
gem.summary = 'Webhook system'
|
12
12
|
gem.description = 'A pluggable webhook subscription system'
|
@@ -18,24 +18,23 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
19
19
|
gem.require_paths = ['lib']
|
20
20
|
|
21
|
-
gem.add_runtime_dependency 'activesupport', '>
|
22
|
-
gem.add_runtime_dependency 'activerecord', '>
|
23
|
-
gem.add_runtime_dependency 'activejob'
|
24
|
-
gem.add_runtime_dependency 'faraday', '
|
21
|
+
gem.add_runtime_dependency 'activesupport', '> 4.2', '< 6.1'
|
22
|
+
gem.add_runtime_dependency 'activerecord', '> 4.2', '< 6.1'
|
23
|
+
gem.add_runtime_dependency 'activejob', '> 4.2', '< 6.1'
|
24
|
+
gem.add_runtime_dependency 'faraday', '> 0.9'
|
25
25
|
gem.add_runtime_dependency 'faraday-encoding', '>= 0.0.2', '< 1.0'
|
26
26
|
gem.add_runtime_dependency 'ph_model'
|
27
27
|
gem.add_runtime_dependency 'validate_url', '~> 1.0'
|
28
28
|
|
29
|
-
gem.add_development_dependency 'bundler', '
|
29
|
+
gem.add_development_dependency 'bundler', '> 1.17', '< 2.5'
|
30
30
|
gem.add_development_dependency 'rake'
|
31
31
|
gem.add_development_dependency 'rspec', '~> 3.0'
|
32
32
|
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
33
33
|
gem.add_development_dependency 'pry'
|
34
34
|
gem.add_development_dependency 'sqlite3'
|
35
35
|
gem.add_development_dependency 'github_changelog_generator', '~> 1.6'
|
36
|
-
gem.add_development_dependency '
|
36
|
+
gem.add_development_dependency 'factory_bot'
|
37
37
|
gem.add_development_dependency 'webmock'
|
38
|
-
gem.add_development_dependency 'appraisal'
|
39
38
|
|
40
39
|
# static analysis gems
|
41
40
|
gem.add_development_dependency 'rubocop', '~> 0.48.1'
|
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.
|
4
|
+
version: 2.3.0
|
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:
|
12
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,54 +17,72 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '4.2'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '6.1'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - ">"
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
30
|
+
version: '4.2'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.1'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: activerecord
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
38
|
- - ">"
|
33
39
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
40
|
+
version: '4.2'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '6.1'
|
35
44
|
type: :runtime
|
36
45
|
prerelease: false
|
37
46
|
version_requirements: !ruby/object:Gem::Requirement
|
38
47
|
requirements:
|
39
48
|
- - ">"
|
40
49
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
50
|
+
version: '4.2'
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '6.1'
|
42
54
|
- !ruby/object:Gem::Dependency
|
43
55
|
name: activejob
|
44
56
|
requirement: !ruby/object:Gem::Requirement
|
45
57
|
requirements:
|
46
|
-
- - "
|
58
|
+
- - ">"
|
47
59
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
60
|
+
version: '4.2'
|
61
|
+
- - "<"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '6.1'
|
49
64
|
type: :runtime
|
50
65
|
prerelease: false
|
51
66
|
version_requirements: !ruby/object:Gem::Requirement
|
52
67
|
requirements:
|
53
|
-
- - "
|
68
|
+
- - ">"
|
54
69
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
70
|
+
version: '4.2'
|
71
|
+
- - "<"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '6.1'
|
56
74
|
- !ruby/object:Gem::Dependency
|
57
75
|
name: faraday
|
58
76
|
requirement: !ruby/object:Gem::Requirement
|
59
77
|
requirements:
|
60
|
-
- - "
|
78
|
+
- - ">"
|
61
79
|
- !ruby/object:Gem::Version
|
62
80
|
version: '0.9'
|
63
81
|
type: :runtime
|
64
82
|
prerelease: false
|
65
83
|
version_requirements: !ruby/object:Gem::Requirement
|
66
84
|
requirements:
|
67
|
-
- - "
|
85
|
+
- - ">"
|
68
86
|
- !ruby/object:Gem::Version
|
69
87
|
version: '0.9'
|
70
88
|
- !ruby/object:Gem::Dependency
|
@@ -119,16 +137,22 @@ dependencies:
|
|
119
137
|
name: bundler
|
120
138
|
requirement: !ruby/object:Gem::Requirement
|
121
139
|
requirements:
|
122
|
-
- - "
|
140
|
+
- - ">"
|
123
141
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
142
|
+
version: '1.17'
|
143
|
+
- - "<"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.5'
|
125
146
|
type: :development
|
126
147
|
prerelease: false
|
127
148
|
version_requirements: !ruby/object:Gem::Requirement
|
128
149
|
requirements:
|
129
|
-
- - "
|
150
|
+
- - ">"
|
130
151
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1.
|
152
|
+
version: '1.17'
|
153
|
+
- - "<"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '2.5'
|
132
156
|
- !ruby/object:Gem::Dependency
|
133
157
|
name: rake
|
134
158
|
requirement: !ruby/object:Gem::Requirement
|
@@ -214,7 +238,7 @@ dependencies:
|
|
214
238
|
- !ruby/object:Gem::Version
|
215
239
|
version: '1.6'
|
216
240
|
- !ruby/object:Gem::Dependency
|
217
|
-
name:
|
241
|
+
name: factory_bot
|
218
242
|
requirement: !ruby/object:Gem::Requirement
|
219
243
|
requirements:
|
220
244
|
- - ">="
|
@@ -241,20 +265,6 @@ dependencies:
|
|
241
265
|
- - ">="
|
242
266
|
- !ruby/object:Gem::Version
|
243
267
|
version: '0'
|
244
|
-
- !ruby/object:Gem::Dependency
|
245
|
-
name: appraisal
|
246
|
-
requirement: !ruby/object:Gem::Requirement
|
247
|
-
requirements:
|
248
|
-
- - ">="
|
249
|
-
- !ruby/object:Gem::Version
|
250
|
-
version: '0'
|
251
|
-
type: :development
|
252
|
-
prerelease: false
|
253
|
-
version_requirements: !ruby/object:Gem::Requirement
|
254
|
-
requirements:
|
255
|
-
- - ">="
|
256
|
-
- !ruby/object:Gem::Version
|
257
|
-
version: '0'
|
258
268
|
- !ruby/object:Gem::Dependency
|
259
269
|
name: rubocop
|
260
270
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,17 +280,16 @@ dependencies:
|
|
270
280
|
- !ruby/object:Gem::Version
|
271
281
|
version: 0.48.1
|
272
282
|
description: A pluggable webhook subscription system
|
273
|
-
email:
|
283
|
+
email: dev@payrollhero.com
|
274
284
|
executables: []
|
275
285
|
extensions: []
|
276
286
|
extra_rdoc_files: []
|
277
287
|
files:
|
278
288
|
- ".codeclimate.yml"
|
289
|
+
- ".github/workflows/build.yml"
|
279
290
|
- ".gitignore"
|
280
291
|
- ".rubocop.hound.yml"
|
281
292
|
- ".rubocop.yml"
|
282
|
-
- ".travis.yml"
|
283
|
-
- Appraisals
|
284
293
|
- CHANGELOG.md
|
285
294
|
- DEPLOYING.md
|
286
295
|
- Gemfile
|
@@ -288,9 +297,13 @@ files:
|
|
288
297
|
- README.md
|
289
298
|
- Rakefile
|
290
299
|
- gemfiles/.bundle/config
|
291
|
-
- gemfiles/rails_4.gemfile
|
292
|
-
- gemfiles/
|
300
|
+
- gemfiles/rails_4.2.gemfile
|
301
|
+
- gemfiles/rails_4.2.gemfile.lock
|
302
|
+
- gemfiles/rails_5.0.gemfile
|
303
|
+
- gemfiles/rails_5.1.gemfile
|
293
304
|
- gemfiles/rails_5_2.gemfile
|
305
|
+
- gemfiles/rails_6.0.gemfile
|
306
|
+
- gemfiles/rails_6.1.gemfile
|
294
307
|
- lib/webhook_system.rb
|
295
308
|
- lib/webhook_system/base_event.rb
|
296
309
|
- lib/webhook_system/encoder.rb
|
@@ -319,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
332
|
- !ruby/object:Gem::Version
|
320
333
|
version: '0'
|
321
334
|
requirements: []
|
322
|
-
rubygems_version: 3.0.
|
335
|
+
rubygems_version: 3.0.9
|
323
336
|
signing_key:
|
324
337
|
specification_version: 4
|
325
338
|
summary: Webhook system
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.1.8
|
4
|
-
- 2.2.4
|
5
|
-
- 2.3.0
|
6
|
-
- 2.5.3
|
7
|
-
- 2.6.3
|
8
|
-
|
9
|
-
gemfile:
|
10
|
-
- gemfiles/rails_4.gemfile
|
11
|
-
- gemfiles/rails_5.gemfile
|
12
|
-
- gemfiles/rails_5_2.gemfile
|
13
|
-
|
14
|
-
|
15
|
-
matrix:
|
16
|
-
exclude:
|
17
|
-
- rvm: 2.1.8
|
18
|
-
gemfile: gemfiles/rails_5.gemfile
|
19
|
-
- rvm: 2.1.8
|
20
|
-
gemfile: gemfiles/rails_5_2.gemfile
|
21
|
-
|
22
|
-
script: "bundle exec rspec"
|
data/Appraisals
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
appraise 'rails-4' do
|
2
|
-
gem 'rails', '~> 4.2.11'
|
3
|
-
gem 'sqlite3', '~> 1.3.6'
|
4
|
-
end
|
5
|
-
|
6
|
-
appraise 'rails-5' do
|
7
|
-
gem 'rails', '~> 5.0.1'
|
8
|
-
gem 'sqlite3', '~> 1.3.6'
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise 'rails-5-2' do
|
12
|
-
gem 'rails', '~> 5.2.1'
|
13
|
-
gem 'sqlite3', '~> 1.4.1'
|
14
|
-
end
|