From bd2c9253f9396009013096ad4cc5e89da295a959 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sat, 29 Mar 2025 18:41:44 -0700 Subject: [PATCH] also use right response for create/put --- server/handle_repo_create_record.go | 2 ++ server/handle_repo_put_record.go | 2 ++ server/repo.go | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/handle_repo_create_record.go b/server/handle_repo_create_record.go index c382ba9..7726435 100644 --- a/server/handle_repo_create_record.go +++ b/server/handle_repo_create_record.go @@ -55,5 +55,7 @@ func (s *Server) handleCreateRecord(e echo.Context) error { return helpers.ServerError(e, nil) } + results[0].Type = nil + return e.JSON(200, results[0]) } diff --git a/server/handle_repo_put_record.go b/server/handle_repo_put_record.go index 44df736..f5138f3 100644 --- a/server/handle_repo_put_record.go +++ b/server/handle_repo_put_record.go @@ -55,5 +55,7 @@ func (s *Server) handlePutRecord(e echo.Context) error { return helpers.ServerError(e, nil) } + results[0].Type = nil + return e.JSON(200, results[0]) } diff --git a/server/repo.go b/server/repo.go index b224d71..f999063 100644 --- a/server/repo.go +++ b/server/repo.go @@ -83,7 +83,7 @@ func (mm *MarshalableMap) MarshalCBOR(w io.Writer) error { } type ApplyWriteResult struct { - Type string `json:"$type,omitempty"` + Type *string `json:"$type,omitempty"` Uri string `json:"uri"` Cid string `json:"cid"` Commit *RepoCommit `json:"commit,omitempty"` @@ -138,7 +138,7 @@ func (rm *RepoMan) applyWrites(urepo models.Repo, writes []Op, swapCommit *strin Value: d, }) results = append(results, ApplyWriteResult{ - Type: OpTypeCreate.String(), + Type: to.StringPtr(OpTypeCreate.String()), Uri: "at://" + urepo.Did + "/" + op.Collection + "/" + *op.Rkey, Cid: nc.String(), ValidationStatus: to.StringPtr("valid"), // TODO: obviously this might not be true atm lol @@ -164,7 +164,7 @@ func (rm *RepoMan) applyWrites(urepo models.Repo, writes []Op, swapCommit *strin Value: d, }) results = append(results, ApplyWriteResult{ - Type: OpTypeUpdate.String(), + Type: to.StringPtr(OpTypeUpdate.String()), Uri: "at://" + urepo.Did + "/" + op.Collection + "/" + *op.Rkey, Cid: nc.String(), ValidationStatus: to.StringPtr("valid"), // TODO: obviously this might not be true atm lol @@ -273,7 +273,7 @@ func (rm *RepoMan) applyWrites(urepo models.Repo, writes []Op, swapCommit *strin } for i := range results { - results[i].Type = results[i].Type + "Result" + results[i].Type = to.StringPtr(*results[i].Type + "Result") results[i].Commit = &RepoCommit{ Cid: newroot.String(), Rev: rev, -- 2.51.2