Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for explicitly setting credential_id on storage #188

Merged
merged 6 commits into from
Sep 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions aries_cloudagent/messaging/credentials/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import json
from json.decoder import JSONDecodeError

from aiohttp import web
from aiohttp_apispec import docs, request_schema, response_schema
Expand Down Expand Up @@ -69,6 +70,12 @@ class CredentialExchangeListSchema(Schema):
results = fields.List(fields.Nested(CredentialExchangeSchema()))


class CredentialStoreRequestSchema(Schema):
"""Request schema for sending a credential store admin message."""

credential_id = fields.Str(required=False)


class CredentialSchema(Schema):
"""Result schema for a credential query."""

Expand Down Expand Up @@ -441,6 +448,7 @@ async def credential_exchange_issue(request: web.BaseRequest):


@docs(tags=["credential_exchange *DEPRECATED*"], summary="Stores a received credential")
@request_schema(CredentialStoreRequestSchema())
@response_schema(CredentialRequestResultSchema(), 200)
async def credential_exchange_store(request: web.BaseRequest):
"""
Expand All @@ -457,8 +465,11 @@ async def credential_exchange_store(request: web.BaseRequest):
context = request.app["request_context"]
outbound_handler = request.app["outbound_message_router"]

body = await request.json()
credential_id = body.get("credential_id")
try:
body = await request.json() or {}
credential_id = body.get("credential_id")
except JSONDecodeError:
credential_id = None

credential_exchange_id = request.match_info["id"]
credential_exchange_record = await CredentialExchange.retrieve_by_id(
Expand Down