From f031cd019e2f3ef342a76c72e53461f037f2ab37 Mon Sep 17 00:00:00 2001 From: Jaz Volpert Date: Thu, 26 Jun 2025 18:06:09 +0000 Subject: [PATCH] Gen new lexicons --- api/atproto/cbor_gen.go | 3 - api/bsky/actordefs.go | 29 ++- api/bsky/cbor_gen.go | 226 +++++++++++++++++- api/bsky/notificationdeclaration.go | 19 ++ api/bsky/notificationdefs.go | 14 ++ .../notificationlistActivitySubscriptions.go | 35 +++ .../notificationputActivitySubscription.go | 33 +++ api/bsky/unspecceddefs.go | 40 ++++ api/bsky/unspeccedgetPostThreadOtherV2.go | 73 ++++++ api/bsky/unspeccedgetPostThreadV2.go | 116 +++++++++ gen/main.go | 1 + 11 files changed, 572 insertions(+), 17 deletions(-) create mode 100644 api/bsky/notificationdeclaration.go create mode 100644 api/bsky/notificationlistActivitySubscriptions.go create mode 100644 api/bsky/notificationputActivitySubscription.go create mode 100644 api/bsky/unspeccedgetPostThreadOtherV2.go create mode 100644 api/bsky/unspeccedgetPostThreadV2.go diff --git a/api/atproto/cbor_gen.go b/api/atproto/cbor_gen.go index 98fd5c87..8f2811b7 100644 --- a/api/atproto/cbor_gen.go +++ b/api/atproto/cbor_gen.go @@ -1206,7 +1206,6 @@ func (t *SyncSubscribeRepos_Sync) UnmarshalCBOR(r io.Reader) (err error) { return nil } - func (t *SyncSubscribeRepos_Identity) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) @@ -1879,7 +1878,6 @@ func (t *SyncSubscribeRepos_Info) UnmarshalCBOR(r io.Reader) (err error) { return nil } - func (t *SyncSubscribeRepos_RepoOp) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) @@ -2094,7 +2092,6 @@ func (t *SyncSubscribeRepos_RepoOp) UnmarshalCBOR(r io.Reader) (err error) { return nil } - func (t *LabelDefs_SelfLabels) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/api/bsky/actordefs.go b/api/bsky/actordefs.go index 96cb02be..dd6f46b7 100644 --- a/api/bsky/actordefs.go +++ b/api/bsky/actordefs.go @@ -379,11 +379,17 @@ func (t *ActorDefs_Preferences_Elem) UnmarshalJSON(b []byte) error { // ActorDefs_ProfileAssociated is a "profileAssociated" in the app.bsky.actor.defs schema. type ActorDefs_ProfileAssociated struct { - Chat *ActorDefs_ProfileAssociatedChat `json:"chat,omitempty" cborgen:"chat,omitempty"` - Feedgens *int64 `json:"feedgens,omitempty" cborgen:"feedgens,omitempty"` - Labeler *bool `json:"labeler,omitempty" cborgen:"labeler,omitempty"` - Lists *int64 `json:"lists,omitempty" cborgen:"lists,omitempty"` - StarterPacks *int64 `json:"starterPacks,omitempty" cborgen:"starterPacks,omitempty"` + ActivitySubscription *ActorDefs_ProfileAssociatedActivitySubscription `json:"activitySubscription,omitempty" cborgen:"activitySubscription,omitempty"` + Chat *ActorDefs_ProfileAssociatedChat `json:"chat,omitempty" cborgen:"chat,omitempty"` + Feedgens *int64 `json:"feedgens,omitempty" cborgen:"feedgens,omitempty"` + Labeler *bool `json:"labeler,omitempty" cborgen:"labeler,omitempty"` + Lists *int64 `json:"lists,omitempty" cborgen:"lists,omitempty"` + StarterPacks *int64 `json:"starterPacks,omitempty" cborgen:"starterPacks,omitempty"` +} + +// ActorDefs_ProfileAssociatedActivitySubscription is a "profileAssociatedActivitySubscription" in the app.bsky.actor.defs schema. +type ActorDefs_ProfileAssociatedActivitySubscription struct { + AllowSubscriptions string `json:"allowSubscriptions" cborgen:"allowSubscriptions"` } // ActorDefs_ProfileAssociatedChat is a "profileAssociatedChat" in the app.bsky.actor.defs schema. @@ -562,11 +568,14 @@ type ActorDefs_VerificationView struct { // // Metadata about the requesting account's relationship with the subject account. Only has meaningful content for authed requests. type ActorDefs_ViewerState struct { - BlockedBy *bool `json:"blockedBy,omitempty" cborgen:"blockedBy,omitempty"` - Blocking *string `json:"blocking,omitempty" cborgen:"blocking,omitempty"` - BlockingByList *GraphDefs_ListViewBasic `json:"blockingByList,omitempty" cborgen:"blockingByList,omitempty"` - FollowedBy *string `json:"followedBy,omitempty" cborgen:"followedBy,omitempty"` - Following *string `json:"following,omitempty" cborgen:"following,omitempty"` + // activitySubscription: This property is present only in selected cases, as an optimization. + ActivitySubscription *NotificationDefs_ActivitySubscription `json:"activitySubscription,omitempty" cborgen:"activitySubscription,omitempty"` + BlockedBy *bool `json:"blockedBy,omitempty" cborgen:"blockedBy,omitempty"` + Blocking *string `json:"blocking,omitempty" cborgen:"blocking,omitempty"` + BlockingByList *GraphDefs_ListViewBasic `json:"blockingByList,omitempty" cborgen:"blockingByList,omitempty"` + FollowedBy *string `json:"followedBy,omitempty" cborgen:"followedBy,omitempty"` + Following *string `json:"following,omitempty" cborgen:"following,omitempty"` + // knownFollowers: This property is present only in selected cases, as an optimization. KnownFollowers *ActorDefs_KnownFollowers `json:"knownFollowers,omitempty" cborgen:"knownFollowers,omitempty"` Muted *bool `json:"muted,omitempty" cborgen:"muted,omitempty"` MutedByList *GraphDefs_ListViewBasic `json:"mutedByList,omitempty" cborgen:"mutedByList,omitempty"` diff --git a/api/bsky/cbor_gen.go b/api/bsky/cbor_gen.go index 2254a434..2ac623e0 100644 --- a/api/bsky/cbor_gen.go +++ b/api/bsky/cbor_gen.go @@ -645,11 +645,35 @@ func (t *FeedRepost) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) + fieldCount := 4 - if _, err := cw.Write([]byte{163}); err != nil { + if t.Via == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } + // t.Via (atproto.RepoStrongRef) (struct) + if t.Via != nil { + + if len("via") > 1000000 { + return xerrors.Errorf("Value in field \"via\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("via"))); err != nil { + return err + } + if _, err := cw.WriteString(string("via")); err != nil { + return err + } + + if err := t.Via.MarshalCBOR(cw); err != nil { + return err + } + } + // t.LexiconTypeID (string) (string) if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") @@ -751,7 +775,27 @@ func (t *FeedRepost) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) + // t.Via (atproto.RepoStrongRef) (struct) + case "via": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Via = new(atproto.RepoStrongRef) + if err := t.Via.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Via pointer: %w", err) + } + } + + } + // t.LexiconTypeID (string) (string) case "$type": { @@ -2756,11 +2800,35 @@ func (t *FeedLike) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) + fieldCount := 4 - if _, err := cw.Write([]byte{163}); err != nil { + if t.Via == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } + // t.Via (atproto.RepoStrongRef) (struct) + if t.Via != nil { + + if len("via") > 1000000 { + return xerrors.Errorf("Value in field \"via\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("via"))); err != nil { + return err + } + if _, err := cw.WriteString(string("via")); err != nil { + return err + } + + if err := t.Via.MarshalCBOR(cw); err != nil { + return err + } + } + // t.LexiconTypeID (string) (string) if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") @@ -2862,7 +2930,27 @@ func (t *FeedLike) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.LexiconTypeID (string) (string) + // t.Via (atproto.RepoStrongRef) (struct) + case "via": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Via = new(atproto.RepoStrongRef) + if err := t.Via.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Via pointer: %w", err) + } + } + + } + // t.LexiconTypeID (string) (string) case "$type": { @@ -9020,3 +9108,133 @@ func (t *ActorStatus) UnmarshalCBOR(r io.Reader) (err error) { return nil } +func (t *NotificationDeclaration) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{162}); 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("app.bsky.notification.declaration"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.notification.declaration")); err != nil { + return err + } + + // t.AllowSubscriptions (string) (string) + if len("allowSubscriptions") > 1000000 { + return xerrors.Errorf("Value in field \"allowSubscriptions\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("allowSubscriptions"))); err != nil { + return err + } + if _, err := cw.WriteString(string("allowSubscriptions")); err != nil { + return err + } + + if len(t.AllowSubscriptions) > 1000000 { + return xerrors.Errorf("Value in field t.AllowSubscriptions was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.AllowSubscriptions))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.AllowSubscriptions)); err != nil { + return err + } + return nil +} + +func (t *NotificationDeclaration) UnmarshalCBOR(r io.Reader) (err error) { + *t = NotificationDeclaration{} + + 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("NotificationDeclaration: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 18) + 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.AllowSubscriptions (string) (string) + case "allowSubscriptions": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.AllowSubscriptions = 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 +} diff --git a/api/bsky/notificationdeclaration.go b/api/bsky/notificationdeclaration.go new file mode 100644 index 00000000..3cdf7bb4 --- /dev/null +++ b/api/bsky/notificationdeclaration.go @@ -0,0 +1,19 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package bsky + +// schema: app.bsky.notification.declaration + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +func init() { + util.RegisterType("app.bsky.notification.declaration", &NotificationDeclaration{}) +} // +// RECORDTYPE: NotificationDeclaration +type NotificationDeclaration struct { + LexiconTypeID string `json:"$type,const=app.bsky.notification.declaration" cborgen:"$type,const=app.bsky.notification.declaration"` + // allowSubscriptions: A declaration of the user's preference for allowing activity subscriptions from other users. Absence of a record implies 'followers'. + AllowSubscriptions string `json:"allowSubscriptions" cborgen:"allowSubscriptions"` +} diff --git a/api/bsky/notificationdefs.go b/api/bsky/notificationdefs.go index ea2f063f..af6b2d0b 100644 --- a/api/bsky/notificationdefs.go +++ b/api/bsky/notificationdefs.go @@ -4,6 +4,12 @@ package bsky // schema: app.bsky.notification.defs +// NotificationDefs_ActivitySubscription is a "activitySubscription" in the app.bsky.notification.defs schema. +type NotificationDefs_ActivitySubscription struct { + Post bool `json:"post" cborgen:"post"` + Reply bool `json:"reply" cborgen:"reply"` +} + // NotificationDefs_ChatPreference is a "chatPreference" in the app.bsky.notification.defs schema. type NotificationDefs_ChatPreference struct { Include string `json:"include" cborgen:"include"` @@ -43,3 +49,11 @@ type NotificationDefs_Preferences struct { // NotificationDefs_RecordDeleted is a "recordDeleted" in the app.bsky.notification.defs schema. type NotificationDefs_RecordDeleted struct { } + +// NotificationDefs_SubjectActivitySubscription is a "subjectActivitySubscription" in the app.bsky.notification.defs schema. +// +// Object used to store activity subscription data in stash. +type NotificationDefs_SubjectActivitySubscription struct { + ActivitySubscription *NotificationDefs_ActivitySubscription `json:"activitySubscription" cborgen:"activitySubscription"` + Subject string `json:"subject" cborgen:"subject"` +} diff --git a/api/bsky/notificationlistActivitySubscriptions.go b/api/bsky/notificationlistActivitySubscriptions.go new file mode 100644 index 00000000..1afe59df --- /dev/null +++ b/api/bsky/notificationlistActivitySubscriptions.go @@ -0,0 +1,35 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package bsky + +// schema: app.bsky.notification.listActivitySubscriptions + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +// NotificationListActivitySubscriptions_Output is the output of a app.bsky.notification.listActivitySubscriptions call. +type NotificationListActivitySubscriptions_Output struct { + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` + Subscriptions []*ActorDefs_ProfileView `json:"subscriptions" cborgen:"subscriptions"` +} + +// NotificationListActivitySubscriptions calls the XRPC method "app.bsky.notification.listActivitySubscriptions". +func NotificationListActivitySubscriptions(ctx context.Context, c util.LexClient, cursor string, limit int64) (*NotificationListActivitySubscriptions_Output, error) { + var out NotificationListActivitySubscriptions_Output + + params := map[string]interface{}{} + if cursor != "" { + params["cursor"] = cursor + } + if limit != 0 { + params["limit"] = limit + } + if err := c.LexDo(ctx, util.Query, "", "app.bsky.notification.listActivitySubscriptions", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/bsky/notificationputActivitySubscription.go b/api/bsky/notificationputActivitySubscription.go new file mode 100644 index 00000000..3ae57a62 --- /dev/null +++ b/api/bsky/notificationputActivitySubscription.go @@ -0,0 +1,33 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package bsky + +// schema: app.bsky.notification.putActivitySubscription + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +// NotificationPutActivitySubscription_Input is the input argument to a app.bsky.notification.putActivitySubscription call. +type NotificationPutActivitySubscription_Input struct { + ActivitySubscription *NotificationDefs_ActivitySubscription `json:"activitySubscription" cborgen:"activitySubscription"` + Subject string `json:"subject" cborgen:"subject"` +} + +// NotificationPutActivitySubscription_Output is the output of a app.bsky.notification.putActivitySubscription call. +type NotificationPutActivitySubscription_Output struct { + ActivitySubscription *NotificationDefs_ActivitySubscription `json:"activitySubscription,omitempty" cborgen:"activitySubscription,omitempty"` + Subject string `json:"subject" cborgen:"subject"` +} + +// NotificationPutActivitySubscription calls the XRPC method "app.bsky.notification.putActivitySubscription". +func NotificationPutActivitySubscription(ctx context.Context, c util.LexClient, input *NotificationPutActivitySubscription_Input) (*NotificationPutActivitySubscription_Output, error) { + var out NotificationPutActivitySubscription_Output + if err := c.LexDo(ctx, util.Procedure, "application/json", "app.bsky.notification.putActivitySubscription", nil, input, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/bsky/unspecceddefs.go b/api/bsky/unspecceddefs.go index 49f43f66..d3322850 100644 --- a/api/bsky/unspecceddefs.go +++ b/api/bsky/unspecceddefs.go @@ -31,6 +31,46 @@ type UnspeccedDefs_SkeletonTrend struct { Topic string `json:"topic" cborgen:"topic"` } +// UnspeccedDefs_ThreadItemBlocked is a "threadItemBlocked" in the app.bsky.unspecced.defs schema. +// +// RECORDTYPE: UnspeccedDefs_ThreadItemBlocked +type UnspeccedDefs_ThreadItemBlocked struct { + LexiconTypeID string `json:"$type,const=app.bsky.unspecced.defs#threadItemBlocked" cborgen:"$type,const=app.bsky.unspecced.defs#threadItemBlocked"` + Author *FeedDefs_BlockedAuthor `json:"author" cborgen:"author"` +} + +// UnspeccedDefs_ThreadItemNoUnauthenticated is a "threadItemNoUnauthenticated" in the app.bsky.unspecced.defs schema. +// +// RECORDTYPE: UnspeccedDefs_ThreadItemNoUnauthenticated +type UnspeccedDefs_ThreadItemNoUnauthenticated struct { + LexiconTypeID string `json:"$type,const=app.bsky.unspecced.defs#threadItemNoUnauthenticated" cborgen:"$type,const=app.bsky.unspecced.defs#threadItemNoUnauthenticated"` +} + +// UnspeccedDefs_ThreadItemNotFound is a "threadItemNotFound" in the app.bsky.unspecced.defs schema. +// +// RECORDTYPE: UnspeccedDefs_ThreadItemNotFound +type UnspeccedDefs_ThreadItemNotFound struct { + LexiconTypeID string `json:"$type,const=app.bsky.unspecced.defs#threadItemNotFound" cborgen:"$type,const=app.bsky.unspecced.defs#threadItemNotFound"` +} + +// UnspeccedDefs_ThreadItemPost is a "threadItemPost" in the app.bsky.unspecced.defs schema. +// +// RECORDTYPE: UnspeccedDefs_ThreadItemPost +type UnspeccedDefs_ThreadItemPost struct { + LexiconTypeID string `json:"$type,const=app.bsky.unspecced.defs#threadItemPost" cborgen:"$type,const=app.bsky.unspecced.defs#threadItemPost"` + // hiddenByThreadgate: The threadgate created by the author indicates this post as a reply to be hidden for everyone consuming the thread. + HiddenByThreadgate bool `json:"hiddenByThreadgate" cborgen:"hiddenByThreadgate"` + // moreParents: This post has more parents that were not present in the response. This is just a boolean, without the number of parents. + MoreParents bool `json:"moreParents" cborgen:"moreParents"` + // moreReplies: This post has more replies that were not present in the response. This is a numeric value, which is best-effort and might not be accurate. + MoreReplies int64 `json:"moreReplies" cborgen:"moreReplies"` + // mutedByViewer: This is by an account muted by the viewer requesting it. + MutedByViewer bool `json:"mutedByViewer" cborgen:"mutedByViewer"` + // opThread: This post is part of a contiguous thread by the OP from the thread root. Many different OP threads can happen in the same thread. + OpThread bool `json:"opThread" cborgen:"opThread"` + Post *FeedDefs_PostView `json:"post" cborgen:"post"` +} + // UnspeccedDefs_TrendView is a "trendView" in the app.bsky.unspecced.defs schema. type UnspeccedDefs_TrendView struct { Actors []*ActorDefs_ProfileViewBasic `json:"actors" cborgen:"actors"` diff --git a/api/bsky/unspeccedgetPostThreadOtherV2.go b/api/bsky/unspeccedgetPostThreadOtherV2.go new file mode 100644 index 00000000..7586cf7a --- /dev/null +++ b/api/bsky/unspeccedgetPostThreadOtherV2.go @@ -0,0 +1,73 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package bsky + +// schema: app.bsky.unspecced.getPostThreadOtherV2 + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +// UnspeccedGetPostThreadOtherV2_Output is the output of a app.bsky.unspecced.getPostThreadOtherV2 call. +type UnspeccedGetPostThreadOtherV2_Output struct { + // thread: A flat list of other thread items. The depth of each item is indicated by the depth property inside the item. + Thread []*UnspeccedGetPostThreadOtherV2_ThreadItem `json:"thread" cborgen:"thread"` +} + +// UnspeccedGetPostThreadOtherV2_ThreadItem is a "threadItem" in the app.bsky.unspecced.getPostThreadOtherV2 schema. +type UnspeccedGetPostThreadOtherV2_ThreadItem struct { + // depth: The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths. + Depth int64 `json:"depth" cborgen:"depth"` + Uri string `json:"uri" cborgen:"uri"` + Value *UnspeccedGetPostThreadOtherV2_ThreadItem_Value `json:"value" cborgen:"value"` +} + +type UnspeccedGetPostThreadOtherV2_ThreadItem_Value struct { + UnspeccedDefs_ThreadItemPost *UnspeccedDefs_ThreadItemPost +} + +func (t *UnspeccedGetPostThreadOtherV2_ThreadItem_Value) MarshalJSON() ([]byte, error) { + if t.UnspeccedDefs_ThreadItemPost != nil { + t.UnspeccedDefs_ThreadItemPost.LexiconTypeID = "app.bsky.unspecced.defs#threadItemPost" + return json.Marshal(t.UnspeccedDefs_ThreadItemPost) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *UnspeccedGetPostThreadOtherV2_ThreadItem_Value) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "app.bsky.unspecced.defs#threadItemPost": + t.UnspeccedDefs_ThreadItemPost = new(UnspeccedDefs_ThreadItemPost) + return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemPost) + + default: + return nil + } +} + +// UnspeccedGetPostThreadOtherV2 calls the XRPC method "app.bsky.unspecced.getPostThreadOtherV2". +// +// anchor: Reference (AT-URI) to post record. This is the anchor post. +// prioritizeFollowedUsers: Whether to prioritize posts from followed users. It only has effect when the user is authenticated. +func UnspeccedGetPostThreadOtherV2(ctx context.Context, c util.LexClient, anchor string, prioritizeFollowedUsers bool) (*UnspeccedGetPostThreadOtherV2_Output, error) { + var out UnspeccedGetPostThreadOtherV2_Output + + params := map[string]interface{}{} + params["anchor"] = anchor + if prioritizeFollowedUsers { + params["prioritizeFollowedUsers"] = prioritizeFollowedUsers + } + if err := c.LexDo(ctx, util.Query, "", "app.bsky.unspecced.getPostThreadOtherV2", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/bsky/unspeccedgetPostThreadV2.go b/api/bsky/unspeccedgetPostThreadV2.go new file mode 100644 index 00000000..b4173b38 --- /dev/null +++ b/api/bsky/unspeccedgetPostThreadV2.go @@ -0,0 +1,116 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package bsky + +// schema: app.bsky.unspecced.getPostThreadV2 + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +// UnspeccedGetPostThreadV2_Output is the output of a app.bsky.unspecced.getPostThreadV2 call. +type UnspeccedGetPostThreadV2_Output struct { + // hasOtherReplies: Whether this thread has additional replies. If true, a call can be made to the `getPostThreadOtherV2` endpoint to retrieve them. + HasOtherReplies bool `json:"hasOtherReplies" cborgen:"hasOtherReplies"` + // thread: A flat list of thread items. The depth of each item is indicated by the depth property inside the item. + Thread []*UnspeccedGetPostThreadV2_ThreadItem `json:"thread" cborgen:"thread"` + Threadgate *FeedDefs_ThreadgateView `json:"threadgate,omitempty" cborgen:"threadgate,omitempty"` +} + +// UnspeccedGetPostThreadV2_ThreadItem is a "threadItem" in the app.bsky.unspecced.getPostThreadV2 schema. +type UnspeccedGetPostThreadV2_ThreadItem struct { + // depth: The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths. + Depth int64 `json:"depth" cborgen:"depth"` + Uri string `json:"uri" cborgen:"uri"` + Value *UnspeccedGetPostThreadV2_ThreadItem_Value `json:"value" cborgen:"value"` +} + +type UnspeccedGetPostThreadV2_ThreadItem_Value struct { + UnspeccedDefs_ThreadItemPost *UnspeccedDefs_ThreadItemPost + UnspeccedDefs_ThreadItemNoUnauthenticated *UnspeccedDefs_ThreadItemNoUnauthenticated + UnspeccedDefs_ThreadItemNotFound *UnspeccedDefs_ThreadItemNotFound + UnspeccedDefs_ThreadItemBlocked *UnspeccedDefs_ThreadItemBlocked +} + +func (t *UnspeccedGetPostThreadV2_ThreadItem_Value) MarshalJSON() ([]byte, error) { + if t.UnspeccedDefs_ThreadItemPost != nil { + t.UnspeccedDefs_ThreadItemPost.LexiconTypeID = "app.bsky.unspecced.defs#threadItemPost" + return json.Marshal(t.UnspeccedDefs_ThreadItemPost) + } + if t.UnspeccedDefs_ThreadItemNoUnauthenticated != nil { + t.UnspeccedDefs_ThreadItemNoUnauthenticated.LexiconTypeID = "app.bsky.unspecced.defs#threadItemNoUnauthenticated" + return json.Marshal(t.UnspeccedDefs_ThreadItemNoUnauthenticated) + } + if t.UnspeccedDefs_ThreadItemNotFound != nil { + t.UnspeccedDefs_ThreadItemNotFound.LexiconTypeID = "app.bsky.unspecced.defs#threadItemNotFound" + return json.Marshal(t.UnspeccedDefs_ThreadItemNotFound) + } + if t.UnspeccedDefs_ThreadItemBlocked != nil { + t.UnspeccedDefs_ThreadItemBlocked.LexiconTypeID = "app.bsky.unspecced.defs#threadItemBlocked" + return json.Marshal(t.UnspeccedDefs_ThreadItemBlocked) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *UnspeccedGetPostThreadV2_ThreadItem_Value) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "app.bsky.unspecced.defs#threadItemPost": + t.UnspeccedDefs_ThreadItemPost = new(UnspeccedDefs_ThreadItemPost) + return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemPost) + case "app.bsky.unspecced.defs#threadItemNoUnauthenticated": + t.UnspeccedDefs_ThreadItemNoUnauthenticated = new(UnspeccedDefs_ThreadItemNoUnauthenticated) + return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemNoUnauthenticated) + case "app.bsky.unspecced.defs#threadItemNotFound": + t.UnspeccedDefs_ThreadItemNotFound = new(UnspeccedDefs_ThreadItemNotFound) + return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemNotFound) + case "app.bsky.unspecced.defs#threadItemBlocked": + t.UnspeccedDefs_ThreadItemBlocked = new(UnspeccedDefs_ThreadItemBlocked) + return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemBlocked) + + default: + return nil + } +} + +// UnspeccedGetPostThreadV2 calls the XRPC method "app.bsky.unspecced.getPostThreadV2". +// +// above: Whether to include parents above the anchor. +// anchor: Reference (AT-URI) to post record. This is the anchor post, and the thread will be built around it. It can be any post in the tree, not necessarily a root post. +// below: How many levels of replies to include below the anchor. +// branchingFactor: Maximum of replies to include at each level of the thread, except for the direct replies to the anchor, which are (NOTE: currently, during unspecced phase) all returned (NOTE: later they might be paginated). +// prioritizeFollowedUsers: Whether to prioritize posts from followed users. It only has effect when the user is authenticated. +// sort: Sorting for the thread replies. +func UnspeccedGetPostThreadV2(ctx context.Context, c util.LexClient, above bool, anchor string, below int64, branchingFactor int64, prioritizeFollowedUsers bool, sort string) (*UnspeccedGetPostThreadV2_Output, error) { + var out UnspeccedGetPostThreadV2_Output + + params := map[string]interface{}{} + if above { + params["above"] = above + } + params["anchor"] = anchor + if below != 0 { + params["below"] = below + } + if branchingFactor != 0 { + params["branchingFactor"] = branchingFactor + } + if prioritizeFollowedUsers { + params["prioritizeFollowedUsers"] = prioritizeFollowedUsers + } + if sort != "" { + params["sort"] = sort + } + if err := c.LexDo(ctx, util.Query, "", "app.bsky.unspecced.getPostThreadV2", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/gen/main.go b/gen/main.go index 3fa2f2d5..338a9c10 100644 --- a/gen/main.go +++ b/gen/main.go @@ -76,6 +76,7 @@ func main() { bsky.FeedPostgate_DisableRule{}, bsky.GraphVerification{}, bsky.ActorStatus{}, + bsky.NotificationDeclaration{}, /*bsky.EmbedImages_View{}, bsky.EmbedRecord_View{}, bsky.EmbedRecordWithMedia_View{}, bsky.EmbedExternal_View{}, bsky.EmbedImages_ViewImage{}, -- 2.51.2