diff --git a/bluesky.go b/bluesky.go index 263df53..afcc5ee 100644 --- a/bluesky.go +++ b/bluesky.go @@ -166,9 +166,9 @@ func (bluesky *Bluesky) DeleteRecord(args []string) *CommitResponse { return resp } -func (bluesky *Bluesky) FetchPost(did string, rkey string) *[]FetchedPost { +func (bluesky *Bluesky) FetchPost(did string, rkey string) Post { resp := &struct { - Posts []FetchedPost `json:"posts"` + Posts []Post `json:"posts"` }{} params := struct { URIs string `url:"uris"` @@ -177,5 +177,5 @@ func (bluesky *Bluesky) FetchPost(did string, rkey string) *[]FetchedPost { } bluesky.sling.New().Base("https://public.api.bsky.app"). Get("/xrpc/app.bsky.feed.getPosts").QueryStruct(¶ms).Receive(resp, resp) - return &resp.Posts + return resp.Posts[0] } diff --git a/client.go b/client.go index 545f6c6..a24b5b0 100644 --- a/client.go +++ b/client.go @@ -15,6 +15,7 @@ import ( type BSky struct { Bluesky *Bluesky + DID string } func NewBSky() *BSky { diff --git a/parse.go b/parse.go index 3126baa..cc88d88 100644 --- a/parse.go +++ b/parse.go @@ -185,26 +185,106 @@ type ParsedEmbeds struct { Height int64 } -type Author struct { - Did string `json:"did"` - Handle string `json:"handle"` - DisplayName string `json:"displayName"` - Avatar string `json:"avatar"` - Associated struct { - Chat struct { - AllowIncoming string `json:"allowIncoming"` - } `json:"chat"` - } `json:"associated"` - Labels []interface{} `json:"labels"` - CreatedAt time.Time `json:"createdAt"` -} - type FetchedPost struct { - URI string `json:"uri"` - Cid string `json:"cid"` - Author *Author `json:"author"` - Record *Post `json:"record"` - Embed *Embed `json:"embed,omitempty"` + URI string `json:"uri"` + Cid string `json:"cid"` + Author struct { + Did string `json:"did"` + Handle string `json:"handle"` + DisplayName string `json:"displayName"` + Avatar string `json:"avatar"` + Associated struct { + Chat struct { + AllowIncoming string `json:"allowIncoming"` + } `json:"chat"` + } `json:"associated"` + Labels []interface{} `json:"labels"` + CreatedAt time.Time `json:"createdAt"` + } `json:"author"` + Record *Post `json:"record"` + Embed struct { + Type string `json:"$type"` + Media struct { + Type string `json:"$type"` + Images []struct { + Thumb string `json:"thumb"` + Fullsize string `json:"fullsize"` + Alt string `json:"alt"` + AspectRatio struct { + Height int `json:"height"` + Width int `json:"width"` + } `json:"aspectRatio"` + } `json:"images"` + } `json:"media"` + Record struct { + Record struct { + Type string `json:"$type"` + URI string `json:"uri"` + Cid string `json:"cid"` + Author struct { + Did string `json:"did"` + Handle string `json:"handle"` + DisplayName string `json:"displayName"` + Avatar string `json:"avatar"` + Associated struct { + Chat struct { + AllowIncoming string `json:"allowIncoming"` + } `json:"chat"` + } `json:"associated"` + Labels []interface{} `json:"labels"` + CreatedAt time.Time `json:"createdAt"` + } `json:"author"` + Value struct { + Type string `json:"$type"` + CreatedAt time.Time `json:"createdAt"` + Embed struct { + Type string `json:"$type"` + AspectRatio struct { + Height int `json:"height"` + Width int `json:"width"` + } `json:"aspectRatio"` + Video struct { + Type string `json:"$type"` + Ref struct { + Link string `json:"$link"` + } `json:"ref"` + MimeType string `json:"mimeType"` + Size int `json:"size"` + } `json:"video"` + } `json:"embed"` + Facets []struct { + Type string `json:"$type"` + Features []struct { + Type string `json:"$type"` + Did string `json:"did"` + } `json:"features"` + Index struct { + ByteEnd int `json:"byteEnd"` + ByteStart int `json:"byteStart"` + } `json:"index"` + } `json:"facets"` + Langs []string `json:"langs"` + Text string `json:"text"` + } `json:"value"` + Labels []interface{} `json:"labels"` + LikeCount int `json:"likeCount"` + ReplyCount int `json:"replyCount"` + RepostCount int `json:"repostCount"` + QuoteCount int `json:"quoteCount"` + IndexedAt time.Time `json:"indexedAt"` + Embeds []struct { + Type string `json:"$type"` + Cid string `json:"cid"` + Playlist string `json:"playlist"` + Thumbnail string `json:"thumbnail"` + AspectRatio struct { + Height int `json:"height"` + Width int `json:"width"` + } `json:"aspectRatio"` + } `json:"embeds"` + } `json:"record"` + } `json:"record"` + } `json:"embed"` ReplyCount int `json:"replyCount"` RepostCount int `json:"repostCount"` LikeCount int `json:"likeCount"`