diff --git a/atproto/auth.go b/atproto/auth.go index 6ea7a52..57d3800 100644 --- a/atproto/auth.go +++ b/atproto/auth.go @@ -46,10 +46,8 @@ var DefaultScopes = []string{ "repo:sh.tangled.repo.artifact", "repo:sh.tangled.repo.collaborator", "repo:sh.tangled.repo.issue", - "repo:sh.tangled.repo.issue.comment", "repo:sh.tangled.repo.issue.state", "repo:sh.tangled.repo.pull", - "repo:sh.tangled.repo.pull.comment", "repo:sh.tangled.repo.pull.status", "repo:sh.tangled.spindle", "repo:sh.tangled.spindle.member", diff --git a/atproto/auth_scope_test.go b/atproto/auth_scope_test.go index 6df7e4a..c7cab4a 100644 --- a/atproto/auth_scope_test.go +++ b/atproto/auth_scope_test.go @@ -14,6 +14,18 @@ func TestDefaultScopesIncludeFeedComment(t *testing.T) { t.Fatal("DefaultScopes does not include repo:sh.tangled.feed.comment") } +func TestDefaultScopesExcludeDeprecatedCommentCollections(t *testing.T) { + deprecatedScopes := map[string]bool{ + "repo:sh.tangled.repo.issue.comment": true, + "repo:sh.tangled.repo.pull.comment": true, + } + for _, scope := range DefaultScopes { + if deprecatedScopes[scope] { + t.Fatalf("DefaultScopes includes deprecated scope %q", scope) + } + } +} + func TestAuthManagerOAuthSessionHasScope(t *testing.T) { store := testKeyringStore(newFakeKeyring()) manager := newAuthManagerForTest("http://127.0.0.1:8095/callback", store) diff --git a/internal/tangledlex/cbor_gen.go b/internal/tangledlex/cbor_gen.go index 6a7b89b..fc17345 100644 --- a/internal/tangledlex/cbor_gen.go +++ b/internal/tangledlex/cbor_gen.go @@ -1889,51 +1889,15 @@ func (t *RepoIssue) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { +func (t *RepoIssueState) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 7 - - if t.Mentions == nil { - fieldCount-- - } - - if t.References == nil { - fieldCount-- - } - - if t.ReplyTo == nil { - fieldCount-- - } - - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err - } - - // t.Body (string) (string) - if len("body") > 1000000 { - return xerrors.Errorf("Value in field \"body\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { - return err - } - if _, err := cw.WriteString(string("body")); err != nil { - return err - } - - if len(t.Body) > 1000000 { - return xerrors.Errorf("Value in field t.Body was too long") - } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Body)); err != nil { + if _, err := cw.Write([]byte{164}); err != nil { return err } @@ -1949,10 +1913,10 @@ func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.comment"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.state"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.issue.comment")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.issue.state")); err != nil { return err } @@ -1979,72 +1943,27 @@ func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { return err } - // t.ReplyTo (string) (string) - if t.ReplyTo != nil { - - if len("replyTo") > 1000000 { - return xerrors.Errorf("Value in field \"replyTo\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("replyTo"))); err != nil { - return err - } - if _, err := cw.WriteString(string("replyTo")); err != nil { - return err - } - - if t.ReplyTo == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.ReplyTo) > 1000000 { - return xerrors.Errorf("Value in field t.ReplyTo was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil { - return err - } - } + // t.State (string) (string) + if len("state") > 1000000 { + return xerrors.Errorf("Value in field \"state\" was too long") } - // t.Mentions ([]string) (slice) - if t.Mentions != nil { - - if len("mentions") > 1000000 { - return xerrors.Errorf("Value in field \"mentions\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil { - return err - } - if _, err := cw.WriteString(string("mentions")); err != nil { - return err - } - - if len(t.Mentions) > 8192 { - return xerrors.Errorf("Slice value in field t.Mentions was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil { - return err - } - for _, v := range t.Mentions { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil { + return err + } + if _, err := cw.WriteString(string("state")); err != nil { + return err + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { - return err - } - if _, err := cw.WriteString(string(v)); err != nil { - return err - } + if len(t.State) > 1000000 { + return xerrors.Errorf("Value in field t.State was too long") + } - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.State)); err != nil { + return err } // t.CreatedAt (string) (string) @@ -2069,47 +1988,11 @@ func (t *RepoIssueComment) MarshalCBOR(w io.Writer) error { if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { return err } - - // t.References ([]string) (slice) - if t.References != nil { - - if len("references") > 1000000 { - return xerrors.Errorf("Value in field \"references\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil { - return err - } - if _, err := cw.WriteString(string("references")); err != nil { - return err - } - - if len(t.References) > 8192 { - return xerrors.Errorf("Slice value in field t.References was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil { - return err - } - for _, v := range t.References { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { - return err - } - if _, err := cw.WriteString(string(v)); err != nil { - return err - } - - } - } return nil } -func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoIssueComment{} +func (t *RepoIssueState) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoIssueState{} cr := cbg.NewCborReader(r) @@ -2128,12 +2011,12 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("RepoIssueComment: map struct too large (%d)", extra) + return fmt.Errorf("RepoIssueState: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 10) + nameBuf := make([]byte, 9) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -2149,18 +2032,7 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Body (string) (string) - case "body": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Body = string(sval) - } - // t.LexiconTypeID (string) (string) + // t.LexiconTypeID (string) (string) case "$type": { @@ -2182,66 +2054,16 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { t.Issue = string(sval) } - // t.ReplyTo (string) (string) - case "replyTo": + // t.State (string) (string) + case "state": { - b, err := cr.ReadByte() + sval, err := cbg.ReadStringWithMax(cr, 1000000) 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.ReplyTo = (*string)(&sval) - } - } - // t.Mentions ([]string) (slice) - case "mentions": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.Mentions: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.Mentions = make([]string, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Mentions[i] = string(sval) - } - - } + t.State = string(sval) } // t.CreatedAt (string) (string) case "createdAt": @@ -2254,267 +2076,29 @@ func (t *RepoIssueComment) UnmarshalCBOR(r io.Reader) (err error) { t.CreatedAt = string(sval) } - // t.References ([]string) (slice) - case "references": - maj, extra, err = cr.ReadHeader() - if err != nil { + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { return err } + } + } - if extra > 8192 { - return fmt.Errorf("t.References: array too large (%d)", extra) - } + return nil +} +func (t *RepoPull) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } + cw := cbg.NewCborWriter(w) + fieldCount := 10 - if extra > 0 { - t.References = make([]string, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.References[i] = string(sval) - } - - } - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *RepoIssueState) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - - if _, err := cw.Write([]byte{164}); err != nil { - return err - } - - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { - return err - } - if _, err := cw.WriteString(string("$type")); err != nil { - return err - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.issue.state"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sh.tangled.repo.issue.state")); err != nil { - return err - } - - // t.Issue (string) (string) - if len("issue") > 1000000 { - return xerrors.Errorf("Value in field \"issue\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("issue"))); err != nil { - return err - } - if _, err := cw.WriteString(string("issue")); err != nil { - return err - } - - if len(t.Issue) > 1000000 { - return xerrors.Errorf("Value in field t.Issue was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Issue))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Issue)); err != nil { - return err - } - - // t.State (string) (string) - if len("state") > 1000000 { - return xerrors.Errorf("Value in field \"state\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil { - return err - } - if _, err := cw.WriteString(string("state")); err != nil { - return err - } - - if len(t.State) > 1000000 { - return xerrors.Errorf("Value in field t.State was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.State)); err != nil { - return err - } - - // t.CreatedAt (string) (string) - if len("createdAt") > 1000000 { - return xerrors.Errorf("Value in field \"createdAt\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { - return err - } - if _, err := cw.WriteString(string("createdAt")); err != nil { - return err - } - - if len(t.CreatedAt) > 1000000 { - return xerrors.Errorf("Value in field t.CreatedAt was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { - return err - } - return nil -} - -func (t *RepoIssueState) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoIssueState{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("RepoIssueState: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 9) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) - case "$type": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.LexiconTypeID = string(sval) - } - // t.Issue (string) (string) - case "issue": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Issue = string(sval) - } - // t.State (string) (string) - case "state": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.State = string(sval) - } - // t.CreatedAt (string) (string) - case "createdAt": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.CreatedAt = string(sval) - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *RepoPull) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - fieldCount := 10 - - if t.Body == nil { - fieldCount-- - } + if t.Body == nil { + fieldCount-- + } if t.DependentOn == nil { fieldCount-- @@ -2565,620 +2149,109 @@ func (t *RepoPull) MarshalCBOR(w io.Writer) error { if _, err := cw.WriteString(string(*t.Body)); err != nil { return err } - } - } - - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { - return err - } - if _, err := cw.WriteString(string("$type")); err != nil { - return err - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil { - return err - } - - // t.Title (string) (string) - if len("title") > 1000000 { - return xerrors.Errorf("Value in field \"title\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil { - return err - } - if _, err := cw.WriteString(string("title")); err != nil { - return err - } - - if len(t.Title) > 1000000 { - return xerrors.Errorf("Value in field t.Title was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Title)); err != nil { - return err - } - - // t.Rounds ([]*tangledlex.RepoPull_Round) (slice) - if len("rounds") > 1000000 { - return xerrors.Errorf("Value in field \"rounds\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("rounds"))); err != nil { - return err - } - if _, err := cw.WriteString(string("rounds")); err != nil { - return err - } - - if len(t.Rounds) > 8192 { - return xerrors.Errorf("Slice value in field t.Rounds was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Rounds))); err != nil { - return err - } - for _, v := range t.Rounds { - if err := v.MarshalCBOR(cw); err != nil { - return err - } - - } - - // t.Source (tangledlex.RepoPull_Source) (struct) - if t.Source != nil { - - if len("source") > 1000000 { - return xerrors.Errorf("Value in field \"source\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { - return err - } - if _, err := cw.WriteString(string("source")); err != nil { - return err - } - - if err := t.Source.MarshalCBOR(cw); err != nil { - return err - } - } - - // t.Target (tangledlex.RepoPull_Target) (struct) - if len("target") > 1000000 { - return xerrors.Errorf("Value in field \"target\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("target"))); err != nil { - return err - } - if _, err := cw.WriteString(string("target")); err != nil { - return err - } - - if err := t.Target.MarshalCBOR(cw); err != nil { - return err - } - - // t.Mentions ([]string) (slice) - if t.Mentions != nil { - - if len("mentions") > 1000000 { - return xerrors.Errorf("Value in field \"mentions\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil { - return err - } - if _, err := cw.WriteString(string("mentions")); err != nil { - return err - } - - if len(t.Mentions) > 8192 { - return xerrors.Errorf("Slice value in field t.Mentions was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil { - return err - } - for _, v := range t.Mentions { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { - return err - } - if _, err := cw.WriteString(string(v)); err != nil { - return err - } - - } - } - - // t.CreatedAt (string) (string) - if len("createdAt") > 1000000 { - return xerrors.Errorf("Value in field \"createdAt\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { - return err - } - if _, err := cw.WriteString(string("createdAt")); err != nil { - return err - } - - if len(t.CreatedAt) > 1000000 { - return xerrors.Errorf("Value in field t.CreatedAt was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { - return err - } - - // t.References ([]string) (slice) - if t.References != nil { - - if len("references") > 1000000 { - return xerrors.Errorf("Value in field \"references\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil { - return err - } - if _, err := cw.WriteString(string("references")); err != nil { - return err - } - - if len(t.References) > 8192 { - return xerrors.Errorf("Slice value in field t.References was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil { - return err - } - for _, v := range t.References { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { - return err - } - if _, err := cw.WriteString(string(v)); err != nil { - return err - } - - } - } - - // t.DependentOn (string) (string) - if t.DependentOn != nil { - - if len("dependentOn") > 1000000 { - return xerrors.Errorf("Value in field \"dependentOn\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("dependentOn"))); err != nil { - return err - } - if _, err := cw.WriteString(string("dependentOn")); err != nil { - return err - } - - if t.DependentOn == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.DependentOn) > 1000000 { - return xerrors.Errorf("Value in field t.DependentOn was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.DependentOn))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.DependentOn)); err != nil { - return err - } - } - } - return nil -} - -func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoPull{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("RepoPull: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 11) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.Body (string) (string) - case "body": - - { - 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.Body = (*string)(&sval) - } - } - // t.LexiconTypeID (string) (string) - case "$type": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.LexiconTypeID = string(sval) - } - // t.Title (string) (string) - case "title": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Title = string(sval) - } - // t.Rounds ([]*tangledlex.RepoPull_Round) (slice) - case "rounds": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.Rounds: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.Rounds = make([]*RepoPull_Round, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Rounds[i] = new(RepoPull_Round) - if err := t.Rounds[i].UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Rounds[i] pointer: %w", err) - } - } - - } - - } - } - // t.Source (tangledlex.RepoPull_Source) (struct) - case "source": - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Source = new(RepoPull_Source) - if err := t.Source.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Source pointer: %w", err) - } - } - - } - // t.Target (tangledlex.RepoPull_Target) (struct) - case "target": - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Target = new(RepoPull_Target) - if err := t.Target.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Target pointer: %w", err) - } - } - - } - // t.Mentions ([]string) (slice) - case "mentions": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.Mentions: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.Mentions = make([]string, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Mentions[i] = string(sval) - } - - } - } - // t.CreatedAt (string) (string) - case "createdAt": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.CreatedAt = string(sval) - } - // t.References ([]string) (slice) - case "references": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.References: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.References = make([]string, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.References[i] = string(sval) - } - - } - } - // t.DependentOn (string) (string) - case "dependentOn": - - { - 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.DependentOn = (*string)(&sval) - } - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} -func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - fieldCount := 6 - - if t.Mentions == nil { - fieldCount-- + } } - if t.References == nil { - fieldCount-- + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") } - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } - - // t.Body (string) (string) - if len("body") > 1000000 { - return xerrors.Errorf("Value in field \"body\" was too long") + if _, err := cw.WriteString(string("$type")); err != nil { + return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil { return err } - if _, err := cw.WriteString(string("body")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil { return err } - if len(t.Body) > 1000000 { - return xerrors.Errorf("Value in field t.Body was too long") + // t.Title (string) (string) + if len("title") > 1000000 { + return xerrors.Errorf("Value in field \"title\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Body)); err != nil { + if _, err := cw.WriteString(string("title")); err != nil { return err } - // t.Pull (string) (string) - if len("pull") > 1000000 { - return xerrors.Errorf("Value in field \"pull\" was too long") + if len(t.Title) > 1000000 { + return xerrors.Errorf("Value in field t.Title was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pull"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil { return err } - if _, err := cw.WriteString(string("pull")); err != nil { + if _, err := cw.WriteString(string(t.Title)); err != nil { return err } - if len(t.Pull) > 1000000 { - return xerrors.Errorf("Value in field t.Pull was too long") + // t.Rounds ([]*tangledlex.RepoPull_Round) (slice) + if len("rounds") > 1000000 { + return xerrors.Errorf("Value in field \"rounds\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Pull))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("rounds"))); err != nil { return err } - if _, err := cw.WriteString(string(t.Pull)); err != nil { + if _, err := cw.WriteString(string("rounds")); err != nil { return err } - // t.LexiconTypeID (string) (string) - if len("$type") > 1000000 { - return xerrors.Errorf("Value in field \"$type\" was too long") + if len(t.Rounds) > 8192 { + return xerrors.Errorf("Slice value in field t.Rounds was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Rounds))); err != nil { return err } - if _, err := cw.WriteString(string("$type")); err != nil { - return err + for _, v := range t.Rounds { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + + // t.Source (tangledlex.RepoPull_Source) (struct) + if t.Source != nil { + + if len("source") > 1000000 { + return xerrors.Errorf("Value in field \"source\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("source"))); err != nil { + return err + } + if _, err := cw.WriteString(string("source")); err != nil { + return err + } + + if err := t.Source.MarshalCBOR(cw); err != nil { + return err + } + } + + // t.Target (tangledlex.RepoPull_Target) (struct) + if len("target") > 1000000 { + return xerrors.Errorf("Value in field \"target\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.comment"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("target"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.repo.pull.comment")); err != nil { + if _, err := cw.WriteString(string("target")); err != nil { + return err + } + + if err := t.Target.MarshalCBOR(cw); err != nil { return err } @@ -3276,11 +2349,43 @@ func (t *RepoPullComment) MarshalCBOR(w io.Writer) error { } } + + // t.DependentOn (string) (string) + if t.DependentOn != nil { + + if len("dependentOn") > 1000000 { + return xerrors.Errorf("Value in field \"dependentOn\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("dependentOn"))); err != nil { + return err + } + if _, err := cw.WriteString(string("dependentOn")); err != nil { + return err + } + + if t.DependentOn == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.DependentOn) > 1000000 { + return xerrors.Errorf("Value in field t.DependentOn was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.DependentOn))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.DependentOn)); err != nil { + return err + } + } + } return nil } -func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { - *t = RepoPullComment{} +func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoPull{} cr := cbg.NewCborReader(r) @@ -3299,12 +2404,12 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("RepoPullComment: map struct too large (%d)", extra) + return fmt.Errorf("RepoPull: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 10) + nameBuf := make([]byte, 11) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -3324,15 +2429,25 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { case "body": { - sval, err := cbg.ReadStringWithMax(cr, 1000000) + b, err := cr.ReadByte() if err != nil { return err } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } - t.Body = string(sval) + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Body = (*string)(&sval) + } } - // t.Pull (string) (string) - case "pull": + // t.LexiconTypeID (string) (string) + case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -3340,10 +2455,10 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.Pull = string(sval) + t.LexiconTypeID = string(sval) } - // t.LexiconTypeID (string) (string) - case "$type": + // t.Title (string) (string) + case "title": { sval, err := cbg.ReadStringWithMax(cr, 1000000) @@ -3351,7 +2466,96 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { return err } - t.LexiconTypeID = string(sval) + t.Title = string(sval) + } + // t.Rounds ([]*tangledlex.RepoPull_Round) (slice) + case "rounds": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Rounds: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Rounds = make([]*RepoPull_Round, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Rounds[i] = new(RepoPull_Round) + if err := t.Rounds[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Rounds[i] pointer: %w", err) + } + } + + } + + } + } + // t.Source (tangledlex.RepoPull_Source) (struct) + case "source": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Source = new(RepoPull_Source) + if err := t.Source.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Source pointer: %w", err) + } + } + + } + // t.Target (tangledlex.RepoPull_Target) (struct) + case "target": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Target = new(RepoPull_Target) + if err := t.Target.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Target pointer: %w", err) + } + } + } // t.Mentions ([]string) (slice) case "mentions": @@ -3444,6 +2648,27 @@ func (t *RepoPullComment) UnmarshalCBOR(r io.Reader) (err error) { } } + // t.DependentOn (string) (string) + case "dependentOn": + + { + 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.DependentOn = (*string)(&sval) + } + } default: // Field doesn't exist on this type, so ignore it diff --git a/internal/tangledlex/cborgen/main.go b/internal/tangledlex/cborgen/main.go index b89ee67..72b6273 100644 --- a/internal/tangledlex/cborgen/main.go +++ b/internal/tangledlex/cborgen/main.go @@ -15,10 +15,8 @@ func main() { lex.PublicKey{}, lex.Repo{}, lex.RepoIssue{}, - lex.RepoIssueComment{}, lex.RepoIssueState{}, lex.RepoPull{}, - lex.RepoPullComment{}, lex.RepoPull_Round{}, lex.RepoPull_Source{}, lex.RepoPullStatus{}, diff --git a/internal/tangledlex/issuecomment.go b/internal/tangledlex/issuecomment.go deleted file mode 100644 index 792ee66..0000000 --- a/internal/tangledlex/issuecomment.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. - -// Lexicon schema: sh.tangled.repo.issue.comment - -package tangledlex - -import ( - lexutil "github.com/bluesky-social/indigo/lex/util" -) - -func init() { - lexutil.RegisterType("sh.tangled.repo.issue.comment", &RepoIssueComment{}) -} - -type RepoIssueComment struct { - LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.repo.issue.comment"` - Body string `json:"body" cborgen:"body"` - CreatedAt string `json:"createdAt" cborgen:"createdAt"` - Issue string `json:"issue" cborgen:"issue"` - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` - References []string `json:"references,omitempty" cborgen:"references,omitempty"` - ReplyTo *string `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` -} diff --git a/internal/tangledlex/pullcomment.go b/internal/tangledlex/pullcomment.go deleted file mode 100644 index 7451592..0000000 --- a/internal/tangledlex/pullcomment.go +++ /dev/null @@ -1,22 +0,0 @@ -// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. - -// Lexicon schema: sh.tangled.repo.pull.comment - -package tangledlex - -import ( - lexutil "github.com/bluesky-social/indigo/lex/util" -) - -func init() { - lexutil.RegisterType("sh.tangled.repo.pull.comment", &RepoPullComment{}) -} - -type RepoPullComment struct { - LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.repo.pull.comment"` - Body string `json:"body" cborgen:"body"` - CreatedAt string `json:"createdAt" cborgen:"createdAt"` - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` - Pull string `json:"pull" cborgen:"pull"` - References []string `json:"references,omitempty" cborgen:"references,omitempty"` -} diff --git a/internal/tangledlex/schemas.txt b/internal/tangledlex/schemas.txt index 0a3c9c8..9a0bacb 100644 --- a/internal/tangledlex/schemas.txt +++ b/internal/tangledlex/schemas.txt @@ -1,10 +1,8 @@ -issue/comment.json issue/issue.json issue/state.json feed/comment.json markup/markdown.json publicKey.json -pulls/comment.json pulls/pull.json pulls/state.json repo/getRepo.json diff --git a/internal/tangledlex/schemas/issue/comment.json b/internal/tangledlex/schemas/issue/comment.json deleted file mode 100644 index 92cb0e5..0000000 --- a/internal/tangledlex/schemas/issue/comment.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "lexicon": 1, - "id": "sh.tangled.repo.issue.comment", - "needsCbor": true, - "needsType": true, - "defs": { - "main": { - "type": "record", - "key": "tid", - "record": { - "type": "object", - "required": ["issue", "body", "createdAt"], - "properties": { - "issue": { - "type": "string", - "format": "at-uri" - }, - "body": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "datetime" - }, - "replyTo": { - "type": "string", - "format": "at-uri" - }, - "mentions": { - "type": "array", - "items": { - "type": "string", - "format": "did" - } - }, - "references": { - "type": "array", - "items": { - "type": "string", - "format": "at-uri" - } - } - } - } - } - } -} diff --git a/internal/tangledlex/schemas/pulls/comment.json b/internal/tangledlex/schemas/pulls/comment.json deleted file mode 100644 index b7ffecd..0000000 --- a/internal/tangledlex/schemas/pulls/comment.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "lexicon": 1, - "id": "sh.tangled.repo.pull.comment", - "needsCbor": true, - "needsType": true, - "defs": { - "main": { - "type": "record", - "key": "tid", - "record": { - "type": "object", - "required": ["pull", "body", "createdAt"], - "properties": { - "pull": { - "type": "string", - "format": "at-uri" - }, - "body": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "datetime" - }, - "mentions": { - "type": "array", - "items": { - "type": "string", - "format": "did" - } - }, - "references": { - "type": "array", - "items": { - "type": "string", - "format": "at-uri" - } - } - } - } - } - } -} diff --git a/internal/tangledlex/validate.go b/internal/tangledlex/validate.go index 97249db..024f6dd 100644 --- a/internal/tangledlex/validate.go +++ b/internal/tangledlex/validate.go @@ -20,16 +20,12 @@ func ValidateRecord(collection string, record any) error { return validateRepo(collection, value) case RepoIssue: return validateIssue(collection, value) - case RepoIssueComment: - return validateIssueComment(collection, value) case FeedComment: return validateFeedComment(collection, value) case RepoIssueState: return validateIssueState(collection, value) case RepoPull: return validatePull(collection, value) - case RepoPullComment: - return validatePullComment(collection, value) case RepoPullStatus: return validatePullStatus(collection, value) case PublicKey: @@ -114,30 +110,6 @@ func validateIssue(collection string, record RepoIssue) error { return datetimeField(record.CreatedAt) } -func validateIssueComment(collection string, record RepoIssueComment) error { - if err := validateType(collection, record.LexiconTypeID, "sh.tangled.repo.issue.comment"); err != nil { - return err - } - if err := atURI(record.Issue); err != nil { - return fieldError("issue", err) - } - if err := required("body", record.Body); err != nil { - return err - } - if record.ReplyTo != nil { - if err := atURI(*record.ReplyTo); err != nil { - return fieldError("replyTo", err) - } - } - if err := validateMentions(record.Mentions); err != nil { - return err - } - if err := validateReferences(record.References); err != nil { - return err - } - return datetimeField(record.CreatedAt) -} - func validateFeedComment(collection string, record FeedComment) error { if err := validateType(collection, record.LexiconTypeID, "sh.tangled.feed.comment"); err != nil { return err @@ -256,25 +228,6 @@ func validatePull(collection string, record RepoPull) error { return datetimeField(record.CreatedAt) } -func validatePullComment(collection string, record RepoPullComment) error { - if err := validateType(collection, record.LexiconTypeID, "sh.tangled.repo.pull.comment"); err != nil { - return err - } - if err := atURI(record.Pull); err != nil { - return fieldError("pull", err) - } - if err := required("body", record.Body); err != nil { - return err - } - if err := validateMentions(record.Mentions); err != nil { - return err - } - if err := validateReferences(record.References); err != nil { - return err - } - return datetimeField(record.CreatedAt) -} - func validatePullStatus(collection string, record RepoPullStatus) error { if err := validateType(collection, record.LexiconTypeID, "sh.tangled.repo.pull.status"); err != nil { return err diff --git a/internal/tangledlex/validate_test.go b/internal/tangledlex/validate_test.go index 7c7aea2..aa3a6bf 100644 --- a/internal/tangledlex/validate_test.go +++ b/internal/tangledlex/validate_test.go @@ -48,11 +48,9 @@ func TestValidateRecordRejectsEveryWritableRecord(t *testing.T) { }{ {"repo", "sh.tangled.repo", Repo{LexiconTypeID: "sh.tangled.repo", CreatedAt: testTime}, "knot"}, {"issue", "sh.tangled.repo.issue", RepoIssue{LexiconTypeID: "sh.tangled.repo.issue", Title: "title", CreatedAt: testTime}, "repo"}, - {"issue comment", "sh.tangled.repo.issue.comment", RepoIssueComment{LexiconTypeID: "sh.tangled.repo.issue.comment", Body: "body", CreatedAt: testTime}, "issue"}, {"feed comment", "sh.tangled.feed.comment", FeedComment{LexiconTypeID: "sh.tangled.feed.comment", Body: &FeedComment_Body{MarkupMarkdown: &MarkupMarkdown{Text: "body"}}, CreatedAt: testTime}, "subject"}, {"issue state", "sh.tangled.repo.issue.state", RepoIssueState{LexiconTypeID: "sh.tangled.repo.issue.state", Issue: testATURI, State: "invalid", CreatedAt: testTime}, "state"}, {"pull", "sh.tangled.repo.pull", RepoPull{LexiconTypeID: "sh.tangled.repo.pull", Title: "title", CreatedAt: testTime}, "target"}, - {"pull comment", "sh.tangled.repo.pull.comment", RepoPullComment{LexiconTypeID: "sh.tangled.repo.pull.comment", Body: "body", CreatedAt: testTime}, "pull"}, {"pull status", "sh.tangled.repo.pull.status", RepoPullStatus{LexiconTypeID: "sh.tangled.repo.pull.status", Pull: testATURI, Status: "invalid", CreatedAt: testTime}, "status"}, {"public key", "sh.tangled.publicKey", PublicKey{LexiconTypeID: "sh.tangled.publicKey", Name: "key", CreatedAt: testTime}, "key"}, {"string", "sh.tangled.string", String{LexiconTypeID: "sh.tangled.string", Contents: "text", CreatedAt: testTime}, "filename"}, @@ -107,16 +105,6 @@ func TestValidateRecordRejectsNestedConstraints(t *testing.T) { }, contains: "mentions", }, - { - name: "issue comment reply", - collection: "sh.tangled.repo.issue.comment", - record: func() any { - record := validRecords()["sh.tangled.repo.issue.comment"].(RepoIssueComment) - record.ReplyTo = stringPointer("not-an-at-uri") - return record - }, - contains: "replyTo", - }, { name: "feed comment subject URI", collection: "sh.tangled.feed.comment", @@ -199,16 +187,6 @@ func TestValidateRecordRejectsNestedConstraints(t *testing.T) { }, contains: "dependentOn", }, - { - name: "pull comment reference", - collection: "sh.tangled.repo.pull.comment", - record: func() any { - record := validRecords()["sh.tangled.repo.pull.comment"].(RepoPullComment) - record.References = []string{"not-an-at-uri"} - return record - }, - contains: "references", - }, } for _, test := range tests { @@ -223,9 +201,8 @@ func TestValidateRecordRejectsNestedConstraints(t *testing.T) { func validRecords() map[string]any { return map[string]any{ - "sh.tangled.repo": Repo{LexiconTypeID: "sh.tangled.repo", Knot: "knot.example", CreatedAt: testTime}, - "sh.tangled.repo.issue": RepoIssue{LexiconTypeID: "sh.tangled.repo.issue", Repo: testDID, Title: "title", CreatedAt: testTime}, - "sh.tangled.repo.issue.comment": RepoIssueComment{LexiconTypeID: "sh.tangled.repo.issue.comment", Issue: testATURI, Body: "body", CreatedAt: testTime}, + "sh.tangled.repo": Repo{LexiconTypeID: "sh.tangled.repo", Knot: "knot.example", CreatedAt: testTime}, + "sh.tangled.repo.issue": RepoIssue{LexiconTypeID: "sh.tangled.repo.issue", Repo: testDID, Title: "title", CreatedAt: testTime}, "sh.tangled.feed.comment": FeedComment{ LexiconTypeID: "sh.tangled.feed.comment", Subject: &comatproto.RepoStrongRef{Uri: testATURI, Cid: testCID}, @@ -243,10 +220,9 @@ func validRecords() map[string]any { PatchBlob: &lexutil.LexBlob{Ref: lexutil.LexLink(cid.MustParse("bafybeigdyrzt5m6b5nkn55vsgzzfw5cfs2tidw6zqugycdkyybf2z7kz4q")), MimeType: "application/gzip"}, }}, }, - "sh.tangled.repo.pull.comment": RepoPullComment{LexiconTypeID: "sh.tangled.repo.pull.comment", Pull: testATURI, Body: "body", CreatedAt: testTime}, - "sh.tangled.repo.pull.status": RepoPullStatus{LexiconTypeID: "sh.tangled.repo.pull.status", Pull: testATURI, Status: "sh.tangled.repo.pull.status.open", CreatedAt: testTime}, - "sh.tangled.publicKey": PublicKey{LexiconTypeID: "sh.tangled.publicKey", Key: "ssh-ed25519 AAAA", Name: "key", CreatedAt: testTime}, - "sh.tangled.string": String{LexiconTypeID: "sh.tangled.string", Filename: "note.md", Description: "note", Contents: "text", CreatedAt: testTime}, + "sh.tangled.repo.pull.status": RepoPullStatus{LexiconTypeID: "sh.tangled.repo.pull.status", Pull: testATURI, Status: "sh.tangled.repo.pull.status.open", CreatedAt: testTime}, + "sh.tangled.publicKey": PublicKey{LexiconTypeID: "sh.tangled.publicKey", Key: "ssh-ed25519 AAAA", Name: "key", CreatedAt: testTime}, + "sh.tangled.string": String{LexiconTypeID: "sh.tangled.string", Filename: "note.md", Description: "note", Contents: "text", CreatedAt: testTime}, } }