discordrb-webhooks 3.7.1 → 3.7.2
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/discordrb/webhooks/client.rb +19 -4
- data/lib/discordrb/webhooks/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 791e80dc497003f6690ab2bff6727dc35574bdfe9335a99b38ef84581f43f561
|
|
4
|
+
data.tar.gz: f5f096cf7d7f78c0c1a42d803d2e294f425ff64a0b9a5136474dfcfe36c839e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 163c5254987d59a81561b98fc5a8f1bf1634c0503e80431024bb8a535e9d02d916de0b19b4d80e94a29a2dbcc512e8f3cd97e25243cd3cabe12edfbc73c06814
|
|
7
|
+
data.tar.gz: 2f3ad3fa91ace42d5c72c612002664703cbd798beb513798f3acad35c12bae1a111c931c50f415333646388380994cf1a6c938cb61b609c5090eb5584b20f618
|
|
@@ -124,20 +124,35 @@ module Discordrb::Webhooks
|
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
def post_json(builder, components, wait, thread_id)
|
|
127
|
-
query = URI.encode_www_form({ wait:, thread_id: }.compact)
|
|
128
127
|
data = builder.to_json_hash.merge({ components: components.to_a })
|
|
129
|
-
RestClient.post(
|
|
128
|
+
RestClient.post(encode_url(wait, thread_id), data.to_json, content_type: :json)
|
|
130
129
|
end
|
|
131
130
|
|
|
132
131
|
def post_multipart(builder, components, wait, thread_id)
|
|
133
|
-
query = URI.encode_www_form({ wait:, thread_id: }.compact)
|
|
134
132
|
data = builder.to_multipart_hash
|
|
135
133
|
data[:components] = components.to_a if components&.to_a&.any?
|
|
136
|
-
RestClient.post(
|
|
134
|
+
RestClient.post(encode_url(wait, thread_id), data.compact)
|
|
137
135
|
end
|
|
138
136
|
|
|
139
137
|
def generate_url(id, token)
|
|
140
138
|
"https://discord.com/api/v9/webhooks/#{id}/#{token}"
|
|
141
139
|
end
|
|
140
|
+
|
|
141
|
+
def encode_url(wait, thread_id)
|
|
142
|
+
uri = URI.parse(@url)
|
|
143
|
+
|
|
144
|
+
# NOTE: We have to use string keys here, since URI#decode_www_form returns
|
|
145
|
+
# string keys, and keys with different types are treated as array query params
|
|
146
|
+
# and appended to the query params twice.
|
|
147
|
+
query = {
|
|
148
|
+
'wait' => wait,
|
|
149
|
+
'thread_id' => thread_id,
|
|
150
|
+
**URI.decode_www_form(uri.query || '').to_h
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
query = URI.encode_www_form(query.compact)
|
|
154
|
+
uri.query = query unless query.empty?
|
|
155
|
+
uri.to_s
|
|
156
|
+
end
|
|
142
157
|
end
|
|
143
158
|
end
|