Skip to content

Commit

Permalink
fix: Return DidResolutionResult in resource_query_handler (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran authored Feb 20, 2025
1 parent 5f5f206 commit aa688a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 109 deletions.
8 changes: 2 additions & 6 deletions services/diddoc/queries/resources/resource_query_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ type ResourceQueryHandler struct {
func (d *ResourceQueryHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) {
// If response is nil, then we need to dereference the resource from the beginning
if response == nil {
resolutionResult, err := c.ResourceService.DereferenceCollectionResources(service.GetDid(), service.GetContentType())
resolutionResult, err := c.ResourceService.ResolveMetadataResources(service.GetDid(), service.GetContentType())
if err != nil {
return nil, err
}
content, ok := resolutionResult.ContentStream.(*types.ResolutionDidDocMetadata)
if !ok {
return nil, types.NewInternalError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing)
}
// Call the next handler
return d.Continue(c, service, types.DidDocMetadataList{*content})
return d.Continue(c, service, resolutionResult)
}
// Otherwise just use the result from previous handlers
// But here we need to cast ContentStream to ResolutionDidDocMetadata
Expand Down
24 changes: 0 additions & 24 deletions services/resource_dereference_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,6 @@ func (rds ResourceService) DereferenceResourceMetadata(did string, resourceId st
return &types.ResourceDereferencing{Context: context, Metadata: metadata, DereferencingMetadata: dereferenceMetadata}, nil
}

func (rds ResourceService) DereferenceCollectionResources(did string, contentType types.ContentType) (*types.ResourceDereferencing, *types.IdentityError) {
dereferenceMetadata := types.NewDereferencingMetadata(did, contentType, "")

didDoc, err := rds.ledgerService.QueryDIDDoc(did, "")
if err != nil {
return nil, err
}

resources, err := rds.ledgerService.QueryCollectionResources(did)
if err != nil {
err.ContentType = contentType
return nil, err
}

var context string
if contentType == types.DIDJSONLD || contentType == types.JSONLD {
context = types.ResolutionSchemaJSONLD
}

contentStream := types.NewResolutionDidDocMetadata(did, didDoc.Metadata, resources)

return &types.ResourceDereferencing{Context: context, ContentStream: contentStream, DereferencingMetadata: dereferenceMetadata}, nil
}

func (rds ResourceService) ResolveMetadataResources(did string, contentType types.ContentType) (*types.DidResolution, *types.IdentityError) {
resolutionMetadata := types.NewResolutionMetadata(did, contentType, "")

Expand Down

This file was deleted.

0 comments on commit aa688a6

Please sign in to comment.