feat: add support for resolving a registry entry when pinning

This commit is contained in:
Derrick Hammer 2024-02-29 12:08:04 -05:00
parent b3df326980
commit 3f2757fb18
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 0 deletions

View File

@ -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 {