Show More
@@ -173,6 +173,18 b' class WebhookSettingsSchema(colander.Sch' | |||
|
173 | 173 | placeholder='secret_token' |
|
174 | 174 | ), |
|
175 | 175 | ) |
|
176 | method_type = colander.SchemaNode( | |
|
177 | colander.String(), | |
|
178 | title=_('Call Method'), | |
|
179 | description=_('Select if the webhook call should be made ' | |
|
180 | 'with POST or GET.'), | |
|
181 | default='post', | |
|
182 | missing='', | |
|
183 | widget=deform.widget.RadioChoiceWidget( | |
|
184 | values=[('get', 'GET'), ('post', 'POST')], | |
|
185 | inline=True | |
|
186 | ), | |
|
187 | ) | |
|
176 | 188 | |
|
177 | 189 | |
|
178 | 190 | class WebhookIntegrationType(IntegrationTypeBase): |
@@ -225,11 +237,11 b' class WebhookIntegrationType(Integration' | |||
|
225 | 237 | url_calls = handler(event, data) |
|
226 | 238 | log.debug('webhook: calling following urls: %s', |
|
227 | 239 | [x[0] for x in url_calls]) |
|
228 | post_to_webhook(url_calls) | |
|
240 | post_to_webhook(url_calls, self.settings) | |
|
229 | 241 | |
|
230 | 242 | |
|
231 | 243 | @task(ignore_result=True) |
|
232 | def post_to_webhook(url_calls): | |
|
244 | def post_to_webhook(url_calls, settings): | |
|
233 | 245 | max_retries = 3 |
|
234 | 246 | for url, token, data in url_calls: |
|
235 | 247 | # retry max N times |
@@ -241,8 +253,13 b' def post_to_webhook(url_calls):' | |||
|
241 | 253 | req_session.mount( |
|
242 | 254 | 'http://', requests.adapters.HTTPAdapter(max_retries=retries)) |
|
243 | 255 | |
|
244 | resp = req_session.post(url, json={ | |
|
256 | method = settings.get('method_type') or 'post' | |
|
257 | call_method = getattr(req_session, method) | |
|
258 | ||
|
259 | log.debug('calling WEBHOOK with method: %s', call_method) | |
|
260 | resp = call_method(url, json={ | |
|
245 | 261 | 'token': token, |
|
246 | 262 | 'event': data |
|
247 | 263 | }) |
|
264 | log.debug('Got WEBHOOK response: %s', resp) | |
|
248 | 265 | resp.raise_for_status() # raise exception on a failed request |
General Comments 0
You need to be logged in to leave comments.
Login now