From 3f2757fb18e7b02bf6880c58747ba33148aa98bb Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 29 Feb 2024 12:08:04 -0500 Subject: [PATCH] feat: add support for resolving a registry entry when pinning --- api/s5/s5.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/s5/s5.go b/api/s5/s5.go index 4c14152..9753357 100644 --- a/api/s5/s5.go +++ b/api/s5/s5.go @@ -904,6 +904,20 @@ func (s *S5API) accountPin(jc jape.Context) { return } + if decodedCid.Type == types.CIDTypeResolver { + entry, err := s.getNode().Services().Registry().Get(decodedCid.Hash.FullBytes()) + if err != nil { + s.sendErrorResponse(jc, NewS5Error(ErrKeyResourceNotFound, err)) + return + } + + decodedCid, err = encoding.CIDFromRegistry(entry.Data()) + if err != nil { + s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err)) + return + } + } + found := true if err := s.accounts.PinByHash(decodedCid.Hash.HashBytes(), userID); err != nil {