From edf321c58c6335641954502c73e7024ad867a16d Mon Sep 17 00:00:00 2001 From: nelind Date: Thu, 29 May 2025 19:32:53 +0200 Subject: [PATCH] lexicons: pulls: remove repo, commentId and owner fields from pull comment records Change-Id: ylnrwruwomoxqvwwuwpwxlsvookoxklx Signed-off-by: nelind --- api/tangled/cbor_gen.go | 189 +----------------------------------- api/tangled/pullcomment.go | 11 +-- appview/pulls/pulls.go | 4 - lexicons/pulls/comment.json | 11 --- 4 files changed, 5 insertions(+), 210 deletions(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 257bf9c..9895996 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -6814,21 +6814,8 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 7 - - if t.CommentId == nil { - fieldCount-- - } - - if t.Owner == nil { - fieldCount-- - } - - if t.Repo == nil { - fieldCount-- - } - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + if _, err := cw.Write([]byte{164}); err != nil { return err } @@ -6878,38 +6865,6 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { return err } - // t.Repo (string) (string) - if t.Repo != nil { - - if len("repo") > 1000000 { - return xerrors.Errorf("Value in field \"repo\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { - return err - } - if _, err := cw.WriteString(string("repo")); err != nil { - return err - } - - if t.Repo == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Repo) > 1000000 { - return xerrors.Errorf("Value in field t.Repo was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Repo)); err != nil { - return err - } - } - } - // t.LexiconTypeID (string) (string) if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") @@ -6929,70 +6884,6 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { return err } - // t.Owner (string) (string) - if t.Owner != nil { - - if len("owner") > 1000000 { - return xerrors.Errorf("Value in field \"owner\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("owner"))); err != nil { - return err - } - if _, err := cw.WriteString(string("owner")); err != nil { - return err - } - - if t.Owner == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Owner) > 1000000 { - return xerrors.Errorf("Value in field t.Owner was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Owner))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Owner)); err != nil { - return err - } - } - } - - // t.CommentId (int64) (int64) - if t.CommentId != nil { - - if len("commentId") > 1000000 { - return xerrors.Errorf("Value in field \"commentId\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commentId"))); err != nil { - return err - } - if _, err := cw.WriteString(string("commentId")); err != nil { - return err - } - - if t.CommentId == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if *t.CommentId >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.CommentId)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.CommentId-1)); err != nil { - return err - } - } - } - - } - // t.CreatedAt (string) (string) if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") @@ -7081,27 +6972,6 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { t.Pull = string(sval) } - // t.Repo (string) (string) - case "repo": - - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Repo = (*string)(&sval) - } - } // t.LexiconTypeID (string) (string) case "$type": @@ -7113,63 +6983,6 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { t.LexiconTypeID = string(sval) } - // t.Owner (string) (string) - case "owner": - - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Owner = (*string)(&sval) - } - } - // t.CommentId (int64) (int64) - case "commentId": - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } - - t.CommentId = (*int64)(&extraI) - } - } // t.CreatedAt (string) (string) case "createdAt": diff --git a/api/tangled/pullcomment.go b/api/tangled/pullcomment.go index 2fdd629..f1da0d8 100644 --- a/api/tangled/pullcomment.go +++ b/api/tangled/pullcomment.go @@ -17,11 +17,8 @@ func init() { } // // RECORDTYPE: RepoPullComment type RepoPullComment struct { - LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.comment" cborgen:"$type,const=sh.tangled.repo.pull.comment"` - Body string `json:"body" cborgen:"body"` - CommentId *int64 `json:"commentId,omitempty" cborgen:"commentId,omitempty"` - CreatedAt string `json:"createdAt" cborgen:"createdAt"` - Owner *string `json:"owner,omitempty" cborgen:"owner,omitempty"` - Pull string `json:"pull" cborgen:"pull"` - Repo *string `json:"repo,omitempty" cborgen:"repo,omitempty"` + LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.comment" cborgen:"$type,const=sh.tangled.repo.pull.comment"` + Body string `json:"body" cborgen:"body"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + Pull string `json:"pull" cborgen:"pull"` } diff --git a/appview/pulls/pulls.go b/appview/pulls/pulls.go index 30ed20a..a833925 100644 --- a/appview/pulls/pulls.go +++ b/appview/pulls/pulls.go @@ -608,7 +608,6 @@ func (s *Pulls) PullComment(w http.ResponseWriter, r *http.Request) { defer tx.Rollback() createdAt := time.Now().Format(time.RFC3339) - ownerDid := user.Did pullAt, err := db.GetPullAt(s.db, f.RepoAt(), pull.PullId) if err != nil { @@ -617,7 +616,6 @@ func (s *Pulls) PullComment(w http.ResponseWriter, r *http.Request) { return } - atUri := f.RepoAt().String() client, err := s.oauth.AuthorizedClient(r) if err != nil { log.Println("failed to get authorized client", err) @@ -630,9 +628,7 @@ func (s *Pulls) PullComment(w http.ResponseWriter, r *http.Request) { Rkey: tid.TID(), Record: &lexutil.LexiconTypeDecoder{ Val: &tangled.RepoPullComment{ - Repo: &atUri, Pull: string(pullAt), - Owner: &ownerDid, Body: body, CreatedAt: createdAt, }, diff --git a/lexicons/pulls/comment.json b/lexicons/pulls/comment.json index 8ecb26d..7946394 100644 --- a/lexicons/pulls/comment.json +++ b/lexicons/pulls/comment.json @@ -19,17 +19,6 @@ "type": "string", "format": "at-uri" }, - "repo": { - "type": "string", - "format": "at-uri" - }, - "commentId": { - "type": "integer" - }, - "owner": { - "type": "string", - "format": "did" - }, "body": { "type": "string" }, -- 2.50.1