diff --git a/bluesky.go b/bluesky.go index afcc5ee..0fbeddb 100644 --- a/bluesky.go +++ b/bluesky.go @@ -166,10 +166,8 @@ func (bluesky *Bluesky) DeleteRecord(args []string) *CommitResponse { return resp } -func (bluesky *Bluesky) FetchPost(did string, rkey string) Post { - resp := &struct { - Posts []Post `json:"posts"` - }{} +func (bluesky *Bluesky) FetchPost(did string, rkey string) FetchedPost { + resp := FetchedPost{} params := struct { URIs string `url:"uris"` }{ @@ -177,5 +175,5 @@ func (bluesky *Bluesky) FetchPost(did string, rkey string) Post { } bluesky.sling.New().Base("https://public.api.bsky.app"). Get("/xrpc/app.bsky.feed.getPosts").QueryStruct(¶ms).Receive(resp, resp) - return resp.Posts[0] + return resp } diff --git a/parse.go b/parse.go index cc88d88..3126baa 100644 --- a/parse.go +++ b/parse.go @@ -185,106 +185,26 @@ 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 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"` + URI string `json:"uri"` + Cid string `json:"cid"` + Author *Author `json:"author"` + Record *Post `json:"record"` + Embed *Embed `json:"embed,omitempty"` ReplyCount int `json:"replyCount"` RepostCount int `json:"repostCount"` LikeCount int `json:"likeCount"`