Remove AsyncResultView because async tasks access the db directly now.

2019-08-17
Marnanel Thurman 2019-05-21 19:10:40 +01:00
rodzic 843db7f95b
commit c42d5c8170
1 zmienionych plików z 0 dodań i 86 usunięć

Wyświetl plik

@ -266,89 +266,3 @@ class InboxView(django.views.View):
# We need to support GET (as a collection)
# but we don't yet.
########################################
class AsyncResultView(django.views.View):
def post(self, request, *args, **kwargs):
uuid_passcode = request.GET['uuid']
success = int(request.GET['success'])!=0
if success:
if not request.body:
logger.warn('Batch notification had success==1 but no body')
return django.http.HttpResponseBadRequest()
body = str(request.body, encoding='UTF-8')
# Why not use request.POST? Because the batch process might
# reasonably use Content-Type: application/activity+json,
# which Django wouldn't recognise as proper JSON, so
# request.POST wouldn't get populated.
# XXX we might want to check the Content-Type here
else:
if request.POST:
logger.warn('Batch notification had success==0 but supplied a body')
return django.http.HttpResponseBadRequest()
body = None
try:
message_need = get_object_or_404(QuarantinedMessageNeeds, id=uuid_passcode)
except ValidationError as e:
logger.warn('Invalid UUID supplied: %s', uuid_passcode)
raise e
except QuarantinedMessageNeeds.NotFound as e:
logger.warn('Batch notification for unknown UUID: %s',
uuid_passcode)
raise e
if success:
logger.info('Batch processing has retrieved %s:',
message_need.needs_to_fetch)
logger.debug(' -- its contents are %s', body)
else:
logger.info('Batch processing has failed to retrieve %s:',
message_need.needs_to_fetch)
if success and body is not None:
try:
fields = json.loads(body)
kepi_create(fields)
except json.decoder.JSONDecodeError:
fields = None
success = False
logger.warn('Body was not JSON. Treating as failure.')
if success:
logger.debug(' -- trying to deploy all matching messages again')
else:
logger.debug(' -- deleting all messages which relied on it')
for need in list(QuarantinedMessageNeeds.objects.filter(
needs_to_fetch = message_need.needs_to_fetch)):
message = need.message
need.delete()
if success:
logger.debug(' -- trying to deploy %s', str(need.message))
message.deploy(retrying=True)
else:
logger.debug(' -- deleting %s', str(need.message))
message.delete()
logger.debug(' -- finished')
return HttpResponse(
status = 200,
reason = 'All is well',
content = '',
content_type = 'text/plain',
)