A social RSS reader built on the AT Protocol. glean.at
glean atproto atmosphere rss feed social app
14
fork

Configure Feed

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

Improve feed discovery

+20
+20
internal/server/feeds_handler.go
··· 4 4 "context" 5 5 "database/sql" 6 6 "errors" 7 + "fmt" 7 8 "net/http" 8 9 "time" 9 10 ··· 91 92 } 92 93 93 94 result, _, _, err := s.fetcher.Fetch(r.Context(), feedURL, "", "") 95 + if err != nil { 96 + result, feedURL, err = s.discoverFeed(r.Context(), feedURL) 97 + } 94 98 if err != nil { 95 99 s.logger.Error("failed to fetch feed", "error", err, "url", feedURL) 96 100 http.Error(w, err.Error(), http.StatusInternalServerError) ··· 445 449 } 446 450 447 451 w.WriteHeader(http.StatusOK) 452 + } 453 + 454 + func (s *Server) discoverFeed(ctx context.Context, feedURL string) (*feed.ParseResult, string, error) { 455 + discovered, err := feed.Discover(ctx, feedURL) 456 + if err != nil || len(discovered.FeedURLs) == 0 { 457 + return nil, feedURL, fmt.Errorf("no feeds found at %s", feedURL) 458 + } 459 + 460 + for _, candidate := range discovered.FeedURLs { 461 + result, _, _, fetchErr := s.fetcher.Fetch(ctx, candidate, "", "") 462 + if fetchErr == nil && result != nil { 463 + return result, candidate, nil 464 + } 465 + } 466 + 467 + return nil, feedURL, fmt.Errorf("no feeds found at %s", feedURL) 448 468 } 449 469 450 470 func nullString(s string) sql.NullString {