From 213ebd0451812fb6dc99ac25b6e7aa3ae6aaacba Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Wed, 20 Aug 2025 19:37:59 +0300 Subject: [PATCH] lexicons,api: remove ids from issue/comment lexicons Change-Id: vlkmykyokoktxwysrosytrxoyurkotvv This hinders atprotation and is very appview-specific anyway. Signed-off-by: Anirudh Oppiliappan --- api/tangled/cbor_gen.go | 124 +----------------------------------- api/tangled/issuecomment.go | 1 - api/tangled/repoissue.go | 1 - appview/issues/issues.go | 13 ++-- lexicons/issue/comment.json | 9 +-- lexicons/issue/issue.json | 11 +--- 6 files changed, 8 insertions(+), 151 deletions(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 257bf9c5..9bf58209 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -5512,7 +5512,7 @@ func (t *RepoIssue) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 7 + fieldCount := 6 if t.Body == nil { fieldCount-- @@ -5642,28 +5642,6 @@ func (t *RepoIssue) MarshalCBOR(w io.Writer) error { return err } - // t.IssueId (int64) (int64) - if len("issueId") > 1000000 { - return xerrors.Errorf("Value in field \"issueId\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issueId"))); err != nil { - return err - } - if _, err := cw.WriteString(string("issueId")); err != nil { - return err - } - - if t.IssueId >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.IssueId)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.IssueId-1)); err != nil { - return err - } - } - // t.CreatedAt (string) (string) if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") @@ -5795,32 +5773,6 @@ func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) { t.Title = string(sval) } - // t.IssueId (int64) (int64) - case "issueId": - { - 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.IssueId = int64(extraI) - } // t.CreatedAt (string) (string) case "createdAt": @@ -5850,11 +5802,7 @@ func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 7 - - if t.CommentId == nil { - fieldCount-- - } + fieldCount := 6 if t.Owner == nil { fieldCount-- @@ -5997,38 +5945,6 @@ func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { } } - // 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") @@ -6170,42 +6086,6 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { 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/issuecomment.go b/api/tangled/issuecomment.go index 0dca3a79..ce9f57d4 100644 --- a/api/tangled/issuecomment.go +++ b/api/tangled/issuecomment.go @@ -19,7 +19,6 @@ func init() { type RepoIssueComment struct { LexiconTypeID string `json:"$type,const=sh.tangled.repo.issue.comment" cborgen:"$type,const=sh.tangled.repo.issue.comment"` Body string `json:"body" cborgen:"body"` - CommentId *int64 `json:"commentId,omitempty" cborgen:"commentId,omitempty"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` Issue string `json:"issue" cborgen:"issue"` Owner *string `json:"owner,omitempty" cborgen:"owner,omitempty"` diff --git a/api/tangled/repoissue.go b/api/tangled/repoissue.go index c35c080b..9f3b8262 100644 --- a/api/tangled/repoissue.go +++ b/api/tangled/repoissue.go @@ -20,7 +20,6 @@ type RepoIssue struct { LexiconTypeID string `json:"$type,const=sh.tangled.repo.issue" cborgen:"$type,const=sh.tangled.repo.issue"` Body *string `json:"body,omitempty" cborgen:"body,omitempty"` CreatedAt string `json:"createdAt" cborgen:"createdAt"` - IssueId int64 `json:"issueId" cborgen:"issueId"` Owner string `json:"owner" cborgen:"owner"` Repo string `json:"repo" cborgen:"repo"` Title string `json:"title" cborgen:"title"` diff --git a/appview/issues/issues.go b/appview/issues/issues.go index 2b6a6a3e..b34f72f1 100644 --- a/appview/issues/issues.go +++ b/appview/issues/issues.go @@ -278,7 +278,6 @@ func (rp *Issues) NewIssueComment(w http.ResponseWriter, r *http.Request) { } createdAt := time.Now().Format(time.RFC3339) - commentIdInt64 := int64(commentId) ownerDid := user.Did issueAt, err := db.GetIssueAt(rp.db, f.RepoAt(), issueIdInt) if err != nil { @@ -302,7 +301,6 @@ func (rp *Issues) NewIssueComment(w http.ResponseWriter, r *http.Request) { Val: &tangled.RepoIssueComment{ Repo: &atUri, Issue: issueAt, - CommentId: &commentIdInt64, Owner: &ownerDid, Body: body, CreatedAt: createdAt, @@ -451,7 +449,6 @@ func (rp *Issues) EditIssueComment(w http.ResponseWriter, r *http.Request) { repoAt := record["repo"].(string) issueAt := record["issue"].(string) createdAt := record["createdAt"].(string) - commentIdInt64 := int64(commentIdInt) _, err = client.RepoPutRecord(r.Context(), &comatproto.RepoPutRecord_Input{ Collection: tangled.RepoIssueCommentNSID, @@ -462,7 +459,6 @@ func (rp *Issues) EditIssueComment(w http.ResponseWriter, r *http.Request) { Val: &tangled.RepoIssueComment{ Repo: &repoAt, Issue: issueAt, - CommentId: &commentIdInt64, Owner: &comment.OwnerDid, Body: newBody, CreatedAt: createdAt, @@ -687,11 +683,10 @@ func (rp *Issues) NewIssue(w http.ResponseWriter, r *http.Request) { Rkey: issue.Rkey, Record: &lexutil.LexiconTypeDecoder{ Val: &tangled.RepoIssue{ - Repo: atUri, - Title: title, - Body: &body, - Owner: user.Did, - IssueId: int64(issue.IssueId), + Repo: atUri, + Title: title, + Body: &body, + Owner: user.Did, }, }, }) diff --git a/lexicons/issue/comment.json b/lexicons/issue/comment.json index 9da3bd6a..7b4e5aae 100644 --- a/lexicons/issue/comment.json +++ b/lexicons/issue/comment.json @@ -9,11 +9,7 @@ "key": "tid", "record": { "type": "object", - "required": [ - "issue", - "body", - "createdAt" - ], + "required": ["issue", "body", "createdAt"], "properties": { "issue": { "type": "string", @@ -23,9 +19,6 @@ "type": "string", "format": "at-uri" }, - "commentId": { - "type": "integer" - }, "owner": { "type": "string", "format": "did" diff --git a/lexicons/issue/issue.json b/lexicons/issue/issue.json index 675b4860..5d775be7 100644 --- a/lexicons/issue/issue.json +++ b/lexicons/issue/issue.json @@ -9,21 +9,12 @@ "key": "tid", "record": { "type": "object", - "required": [ - "repo", - "issueId", - "owner", - "title", - "createdAt" - ], + "required": ["repo", "owner", "title", "createdAt"], "properties": { "repo": { "type": "string", "format": "at-uri" }, - "issueId": { - "type": "integer" - }, "owner": { "type": "string", "format": "did" -- 2.43.0