webhookdump 0.0.3 → 0.0.5
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/lib/version.rb +1 -1
- data/lib/webhook_dump.rb +20 -5
- 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: 976fd8974e7388af85639b08f57d932998bf1127ebcc65858f34e67353e9647c
|
4
|
+
data.tar.gz: 146b4246ccfc22144b89f817677dcfa96334da61ec038fd5429bbe510f036bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fd044b73a0e0653c2a110b2b4d8244bc40796b79eab92819b922da5533d7a5b86222f03da7affc9d9a68b12ffcf828c34df9cb3c6cfb301d1b9fa9f97bc7476
|
7
|
+
data.tar.gz: 30c3dec40840ace2ca8a74ae5ddb6cda6a2163e8907c87b7d1c7dfc5688028ddd6793b49cdb414b17a81bd5a3fe4c28ca51d8be7e79f3f3705a783b19f97c29e
|
data/lib/version.rb
CHANGED
data/lib/webhook_dump.rb
CHANGED
@@ -6,14 +6,16 @@ require 'faraday'
|
|
6
6
|
|
7
7
|
module WebhookDump
|
8
8
|
class CLI < Thor
|
9
|
-
|
10
|
-
|
9
|
+
WEBSOCKET_HOST = 'webhookdump.link'
|
10
|
+
WEBSOCKET_HOST_DEV = 'localhost:3000'
|
11
11
|
|
12
12
|
option :dev, type: :boolean, default: false, desc: 'Use development environment'
|
13
13
|
|
14
14
|
desc "forward WEBHOOKDUMP_ID FORWARD_URL", "Forward events from WebhookDump to a target URL"
|
15
15
|
|
16
16
|
def forward(webhookdump_id, forward_url)
|
17
|
+
validate_settings(webhookdump_id, forward_url)
|
18
|
+
|
17
19
|
EM.run do
|
18
20
|
puts "Start forwarding events from WebhookDump #{webhookdump_id} to #{forward_url}"
|
19
21
|
|
@@ -61,7 +63,7 @@ module WebhookDump
|
|
61
63
|
|
62
64
|
def close_websocket_connection(ws)
|
63
65
|
ws.on :close do |event|
|
64
|
-
reason = event.reason != ' ' ? '
|
66
|
+
reason = event.reason != ' ' ? 'Invalid WebhookDump ID' : event.reason
|
65
67
|
puts "Connection closed, #{event.code}, #{reason}"
|
66
68
|
|
67
69
|
EM.stop
|
@@ -69,11 +71,18 @@ module WebhookDump
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def init_faye_websocket_connection(webhookdump_id)
|
72
|
-
Faye::WebSocket::Client.new("#{
|
74
|
+
Faye::WebSocket::Client.new("#{websocket_url}?id=#{webhookdump_id}")
|
75
|
+
end
|
76
|
+
|
77
|
+
def websocket_host
|
78
|
+
options[:dev] ? WEBSOCKET_HOST_DEV : WEBSOCKET_HOST
|
73
79
|
end
|
74
80
|
|
75
81
|
def websocket_url
|
76
|
-
|
82
|
+
protocol = 'wss'
|
83
|
+
protocol = 'ws' if options[:dev]
|
84
|
+
|
85
|
+
"#{protocol}://#{websocket_host}/cable"
|
77
86
|
end
|
78
87
|
|
79
88
|
def forward_message(forward_url, message)
|
@@ -114,6 +123,12 @@ module WebhookDump
|
|
114
123
|
|
115
124
|
{}
|
116
125
|
end
|
126
|
+
|
127
|
+
def validate_settings(webhookdump_id, forward_url)
|
128
|
+
if forward_url.include? "#{websocket_host}/#{webhookdump_id}"
|
129
|
+
puts "Error: Forward URL is the same as the incoming request URL. This would cause an infinite loop."
|
130
|
+
exit 1
|
131
|
+
end
|
117
132
|
end
|
118
133
|
end
|
119
134
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webhookdump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Risal Hidayat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|