From 13249d564f32fe2a315881ef3ddc68de8f3a7949 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 28 Nov 2024 18:48:50 +0100 Subject: [PATCH] fix call to proofs --- dpp/views.py | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/dpp/views.py b/dpp/views.py index 372bb17..fe0d6ed 100644 --- a/dpp/views.py +++ b/dpp/views.py @@ -1,11 +1,13 @@ +import json import logging + from django.views.generic.edit import View from django.http import JsonResponse -from evidence.xapian import search -from dpp.models import Proof from dpp.api_dlt import ALGORITHM - +from evidence.models import Evidence +from evidence.parse import Build +from dpp.models import Proof logger = logging.getLogger('django') @@ -20,27 +22,23 @@ class ProofView(View): proof = Proof.objects.filter(timestamp=timestamp).first() if not proof: return JsonResponse({}, status=404) - - ev_uuid = 'uuid:"{}"'.format(proof.uuid) - matches = search(None, ev_uuid, limit=1) - if not matches or matches.size() < 1: + + ev = Evidence(proof.uuid) + if not ev.doc: return JsonResponse({}, status=404) - for x in matches: - snap = x.document.get_data() - - data = { - "algorithm": ALGORITHM, - "document": snap - } + dev = Build(ev.doc, None, check=True) + doc = dev.get_phid() - d = { - '@context': ['https://ereuse.org/proof0.json'], - 'data': data, - } - response = JsonResponse(d, status=200) - response["Access-Control-Allow-Origin"] = "*" - return response - - return JsonResponse({}, status=404) + data = { + "algorithm": ALGORITHM, + "document": json.dumps(doc) + } + d = { + '@context': ['https://ereuse.org/proof0.json'], + 'data': data, + } + response = JsonResponse(d, status=200) + response["Access-Control-Allow-Origin"] = "*" + return response