nandi/gleanpublic Fork 0
3fe5441
Commits
Clone
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Remove redundant feed fetchingUnverified

Julien Robert committed 2026-04-23T20:08:08+02:00 Browse files
3fe5441 parent: 8c01260
modified internal/server/server.go +0 -43
@@ -381,56 +381,13 @@ func (s *Server) syncUserInBackground(userDID string, client *atproto.Client) {
381381 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
382382 defer cancel()
383383
384- isNewUser := false
385- if count, err := s.dbs.Articles.GetSubscriptionCount(ctx, userDID); err == nil && count == 0 {
386- isNewUser = true
387- }
388-
389384 sync := atproto.NewSync(s.dbs.Articles, s.dbs.Users, client, s.logger)
390385 if err := sync.Run(ctx, userDID); err != nil {
391386 s.logger.Error("background sync failed", "error", err, "did", userDID)
392387 }
393-
394- if isNewUser {
395- s.refreshUserFeeds(ctx, userDID)
396- }
397388 }()
398389 }
399390
400-func (s *Server) refreshUserFeeds(ctx context.Context, userDID string) {
401- subs, err := s.dbs.Articles.ListSubscriptions(ctx, userDID, "", 1000, 0)
402- if err != nil {
403- s.logger.Error("failed to list subscriptions for initial fetch", "error", err, "did", userDID)
404- return
405- }
406-
407- // Fetch each feed once, even if many users subscribe to the same feed.
408- // Dead feeds (error_count >= 25) are intentionally retried here so a new
409- // user's subscriptions get a chance to succeed before being gated by the
410- // scheduler's error_count filter.
411- seen := make(map[string]bool, len(subs))
412- for _, sub := range subs {
413- if seen[sub.FeedURL] {
414- continue
415- }
416- seen[sub.FeedURL] = true
417-
418- f, err := s.dbs.Articles.GetFeed(ctx, sub.FeedURL)
419- if err != nil {
420- continue
421- }
422- s.scheduler.FetchFeed(ctx, &feed.Feed{
423- URL: f.FeedURL,
424- Title: f.Title.String,
425- SiteURL: f.SiteURL.String,
426- Description: f.Description.String,
427- Type: f.FeedType.String,
428- ETag: f.Etag.String,
429- LastModified: f.LastModified.String,
430- })
431- }
432-}
433-
434391 func (s *Server) PeriodicSync(ctx context.Context, interval time.Duration) {
435392 ticker := time.NewTicker(interval)
436393 defer ticker.Stop()
@@ -381,56 +381,13 @@ func (s *Server) syncUserInBackground(userDID string, client *atproto.Client) {
381 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)381 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
382 defer cancel()382 defer cancel()
383 383
384- isNewUser := false
385- if count, err := s.dbs.Articles.GetSubscriptionCount(ctx, userDID); err == nil && count == 0 {
386- isNewUser = true
387- }
388-
389 sync := atproto.NewSync(s.dbs.Articles, s.dbs.Users, client, s.logger)384 sync := atproto.NewSync(s.dbs.Articles, s.dbs.Users, client, s.logger)
390 if err := sync.Run(ctx, userDID); err != nil {385 if err := sync.Run(ctx, userDID); err != nil {
391 s.logger.Error("background sync failed", "error", err, "did", userDID)386 s.logger.Error("background sync failed", "error", err, "did", userDID)
392 }387 }
393-
394- if isNewUser {
395- s.refreshUserFeeds(ctx, userDID)
396- }
397 }()388 }()
398 }389 }
399 390
400-func (s *Server) refreshUserFeeds(ctx context.Context, userDID string) {
401- subs, err := s.dbs.Articles.ListSubscriptions(ctx, userDID, "", 1000, 0)
402- if err != nil {
403- s.logger.Error("failed to list subscriptions for initial fetch", "error", err, "did", userDID)
404- return
405- }
406-
407- // Fetch each feed once, even if many users subscribe to the same feed.
408- // Dead feeds (error_count >= 25) are intentionally retried here so a new
409- // user's subscriptions get a chance to succeed before being gated by the
410- // scheduler's error_count filter.
411- seen := make(map[string]bool, len(subs))
412- for _, sub := range subs {
413- if seen[sub.FeedURL] {
414- continue
415- }
416- seen[sub.FeedURL] = true
417-
418- f, err := s.dbs.Articles.GetFeed(ctx, sub.FeedURL)
419- if err != nil {
420- continue
421- }
422- s.scheduler.FetchFeed(ctx, &feed.Feed{
423- URL: f.FeedURL,
424- Title: f.Title.String,
425- SiteURL: f.SiteURL.String,
426- Description: f.Description.String,
427- Type: f.FeedType.String,
428- ETag: f.Etag.String,
429- LastModified: f.LastModified.String,
430- })
431- }
432-}
433-
434 func (s *Server) PeriodicSync(ctx context.Context, interval time.Duration) {391 func (s *Server) PeriodicSync(ctx context.Context, interval time.Duration) {
435 ticker := time.NewTicker(interval)392 ticker := time.NewTicker(interval)
436 defer ticker.Stop()393 defer ticker.Stop()