MCPcopy Create free account
hub / github.com/bcspragu/logseq-sync / getGraphSalt

Method getGraphSalt

cmd/server/main.go:615–633  ·  view source on GitHub ↗
(ctx context.Context, req *getGraphSaltRequest)

Source from the content-addressed store, hash-verified

613}
614
615func (s *server) getGraphSalt(ctx context.Context, req *getGraphSaltRequest) (*getGraphSaltResponse, error) {
616 salts, err := s.db.GraphSalts(ctx, db.GraphID(req.GraphUUID))
617 if db.IsNotExists(err) {
618 return nil, httperr.NotFound("graph %q wasn't found", req.GraphUUID)
619 } else if err != nil {
620 return nil, httperr.Internal("failed to load graph salts: %w", err)
621 }
622 if len(salts) == 0 {
623 // This was observed in the original API
624 return nil, httperr.Gone("no salts in graph %q", req.GraphUUID)
625 }
626 salt := salts[len(salts)-1]
627
628 // XXX: The end salt is the latest, which maybe isn't a great assumption to bake into our DB API.
629 return &getGraphSaltResponse{
630 Value: base64.StdEncoding.EncodeToString(salt.Value),
631 ExpiredAt: salt.ExpiredAt.UnixMilli(),
632 }, nil
633}
634
635type uploadGraphEncryptKeysRequest struct {
636 EncryptedPrivateKey string `json:"encrypted-private-key"`

Callers

nothing calls this directly

Calls 6

GraphIDTypeAlias · 0.92
IsNotExistsFunction · 0.92
NotFoundFunction · 0.92
InternalFunction · 0.92
GoneFunction · 0.92
GraphSaltsMethod · 0.65

Tested by

no test coverage detected