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:
|
if self.run_async:
|
||||||
async_task(self._process_payload, message.id)
|
async_task(self._process_payload, message.id)
|
||||||
else:
|
else:
|
||||||
message.worked_on = self.webhook.process_payload(message, payload, headers)
|
self.process_result(
|
||||||
message.save()
|
self.webhook.process_payload(message, payload, headers),
|
||||||
|
message,
|
||||||
|
)
|
||||||
|
|
||||||
# return results
|
# return results
|
||||||
data = self.webhook.get_result(payload, headers, request)
|
data = self.webhook.get_result(payload, headers, request)
|
||||||
@ -66,9 +68,17 @@ class WebhookView(CsrfExemptMixin, APIView):
|
|||||||
|
|
||||||
def _process_payload(self, message_id):
|
def _process_payload(self, message_id):
|
||||||
message = WebhookMessage.objects.get(message_id=message_id)
|
message = WebhookMessage.objects.get(message_id=message_id)
|
||||||
process_result = self.webhook.process_payload(message, message.body, message.header)
|
self.process_result(
|
||||||
message.worked_on = 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()
|
message.save()
|
||||||
|
else:
|
||||||
|
message.delete()
|
||||||
|
|
||||||
def _escalate_object(self, obj):
|
def _escalate_object(self, obj):
|
||||||
classes = inheritors(obj.__class__)
|
classes = inheritors(obj.__class__)
|
||||||
|
Loading…
Reference in New Issue
Block a user