Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
Go
at sl/profile
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980package models
import ( "time"
apibsky "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/atproto/syntax")
type BskyPost struct { AuthorDid string Rkey string Text string CreatedAt time.Time Langs []string Tags []string Embed *apibsky.FeedDefs_PostView_Embed Facets []*apibsky.RichtextFacet Labels *apibsky.FeedPost_Labels Reply *apibsky.FeedPost_ReplyRef LikeCount int64 ReplyCount int64 RepostCount int64 QuoteCount int64}
func NewBskyPostFromView(postView *apibsky.FeedDefs_PostView) (*BskyPost, error) { atUri, err := syntax.ParseATURI(postView.Uri) if err != nil { return nil, err }
// decode the record to get FeedPost feedPost, ok := postView.Record.Val.(*apibsky.FeedPost) if !ok { return nil, err }
createdAt, err := time.Parse(time.RFC3339, feedPost.CreatedAt) if err != nil { return nil, err }
var likeCount, replyCount, repostCount, quoteCount int64 if postView.LikeCount != nil { likeCount = *postView.LikeCount } if postView.ReplyCount != nil { replyCount = *postView.ReplyCount } if postView.RepostCount != nil { repostCount = *postView.RepostCount } if postView.QuoteCount != nil { quoteCount = *postView.QuoteCount }
post := &BskyPost{ Rkey: atUri.RecordKey().String(), Text: feedPost.Text, CreatedAt: createdAt, Langs: feedPost.Langs, Tags: feedPost.Tags, Embed: postView.Embed, Facets: feedPost.Facets, Labels: feedPost.Labels, Reply: feedPost.Reply, LikeCount: likeCount, ReplyCount: replyCount, RepostCount: repostCount, QuoteCount: quoteCount, }
if author := postView.Author; author != nil { post.AuthorDid = author.Did }
return post, nil}