this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

when finding a /subsribe, add the parent URI to ones to look for replies for and then pass the replies to the feed gen

+15 -8
+14 -7
consumer.go
··· 6 6 "fmt" 7 7 "log" 8 8 "log/slog" 9 + "slices" 9 10 "time" 10 11 11 12 apibsky "github.com/bluesky-social/indigo/api/bsky" ··· 59 60 } 60 61 61 62 type handler struct { 62 - seenSeqs map[int64]struct{} 63 - highwater int64 64 - feedGenerator *FeedGenerator 63 + seenSeqs map[int64]struct{} 64 + highwater int64 65 + feedGenerator *FeedGenerator 66 + parentsToLookFor []string 65 67 } 66 68 67 69 func (h *handler) HandleEvent(ctx context.Context, event *models.Event) error { ··· 74 76 return fmt.Errorf("failed to unmarshal post: %w", err) 75 77 } 76 78 77 - // only look for posts where I've "subsribed" 78 - if post.Text != "/subscribe" { 79 + // look for posts where I've "subsribed" so that we can add the parent URI to a list of replies to that parent to look for 80 + if post.Text == "/subscribe" { 81 + if post.Reply != nil && post.Reply.Parent != nil && post.Reply.Parent.Uri != "" { 82 + slog.Info("it's a reply with a parent! Adding to parents to look for", "parent URI", post.Reply.Parent.Uri) 83 + 84 + } 79 85 return nil 80 86 } 81 87 82 88 if post.Reply != nil && post.Reply.Parent != nil && post.Reply.Parent.Uri != "" { 83 - slog.Info("it's a reply with a parent! Adding to feeds", "parent URI", post.Reply.Parent.Uri) 84 - h.feedGenerator.AddToFeed(post.Reply.Parent.Uri) 89 + if slices.Contains(h.parentsToLookFor, post.Reply.Parent.Uri) { 90 + h.feedGenerator.AddToFeed(fmt.Sprintf("at://%s", event.Did)) 91 + } 85 92 } 86 93 } 87 94 }
+1 -1
main.go
··· 61 61 62 62 var closeErr *websocket.CloseError 63 63 if errors.As(err, &closeErr) { 64 - if closeErr.Code == websocket.CloseAbnormalClosure && continueCount <= 10 { 64 + if closeErr.Code == websocket.CloseAbnormalClosure && continueCount <= 100 { 65 65 slog.Error("consume - trying again", "error", err) 66 66 continueCount++ 67 67 continue