outgoing_webhook: Join build_bot_request and send_data_to_server.

The existing organization, of returning an opaque blob from
`build_bot_request`, which was later consumed by
`send_data_to_server`, is not particularly sensible; the steps become
oddly split between the OutgoingWebhookWorker, `do_rest_call`, and the
`OutgoingWebhookServiceInterface`.

Make the `OutgoingWebhookServiceInterface` in charge of building,
making, and returning the request in one method; another method
handles extracting content from a successful response.  `do_rest_call`
is responsible for calling both halves of this, and doing common error
handling.
This commit is contained in:
Alex Vandiver
2021-03-26 19:11:40 -07:00
committed by Tim Abbott
parent be706ea7a1
commit a280905a89
4 changed files with 82 additions and 44 deletions

View File

@@ -742,9 +742,7 @@ class OutgoingWebhookWorker(QueueProcessingWorker):
for service in services:
event["service_name"] = str(service.name)
service_handler = get_outgoing_webhook_service_handler(service)
request_data = service_handler.build_bot_request(event)
if request_data:
do_rest_call(service.base_url, request_data, event, service_handler)
do_rest_call(service.base_url, event, service_handler)
@assign_queue("embedded_bots")