Monorepo for Tangled
at f887743001ec3f0f95f90c1a4d807cb37d9132d7 43 lines 944 B view raw
1package bsky 2 3import ( 4 "context" 5 "log" 6 7 bsky "github.com/bluesky-social/indigo/api/bsky" 8 "github.com/bluesky-social/indigo/xrpc" 9 "tangled.org/core/appview/models" 10 "tangled.org/core/consts" 11) 12 13func FetchPosts(ctx context.Context, c *xrpc.Client, limit int, cursor string) ([]models.BskyPost, string, error) { 14 resp, err := bsky.FeedGetAuthorFeed(ctx, c, consts.TangledDid, cursor, "posts_no_replies", false, int64(limit)) 15 if err != nil { 16 return nil, "", err 17 } 18 19 var posts []models.BskyPost 20 for _, feedViewPost := range resp.Feed { 21 // skip quote posts 22 if feedViewPost.Post.Embed != nil && feedViewPost.Post.Embed.EmbedRecord_View != nil { 23 continue 24 } 25 26 post, err := models.NewBskyPostFromView(feedViewPost.Post) 27 if err != nil { 28 log.Println(err) 29 continue 30 } 31 32 posts = append(posts, *post) 33 } 34 35 return posts, stringPtr(resp.Cursor), nil 36} 37 38func stringPtr(s *string) string { 39 if s == nil { 40 return "" 41 } 42 return *s 43}