mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor result processing
This commit is contained in:
parent
1b72dfeae6
commit
a03c560914
@ -57,8 +57,10 @@ class WebhookView(CsrfExemptMixin, APIView):
|
||||
if self.run_async:
|
||||
async_task(self._process_payload, message.id)
|
||||
else:
|
||||
message.worked_on = self.webhook.process_payload(message, payload, headers)
|
||||
message.save()
|
||||
self.process_result(
|
||||
self.webhook.process_payload(message, payload, headers),
|
||||
message,
|
||||
)
|
||||
|
||||
# return results
|
||||
data = self.webhook.get_result(payload, headers, request)
|
||||
@ -66,9 +68,17 @@ class WebhookView(CsrfExemptMixin, APIView):
|
||||
|
||||
def _process_payload(self, message_id):
|
||||
message = WebhookMessage.objects.get(message_id=message_id)
|
||||
process_result = self.webhook.process_payload(message, message.body, message.header)
|
||||
message.worked_on = process_result
|
||||
self.process_result(
|
||||
self.webhook.process_payload(message, message.body, message.header),
|
||||
message,
|
||||
)
|
||||
|
||||
def process_result(self, result, message):
|
||||
if result:
|
||||
message.worked_on = result
|
||||
message.save()
|
||||
else:
|
||||
message.delete()
|
||||
|
||||
def _escalate_object(self, obj):
|
||||
classes = inheritors(obj.__class__)
|
||||
|
Loading…
Reference in New Issue
Block a user