1
0
Fork 0

Miscellaneous improvements to internal/reader/subscription/finder.go

- Surface `localizedError` in FindSubscriptionsFromWellKnownURLs via slog
- Use an inline declaration for new subscriptions, like done elsewhere in the
  file, if only for consistency's sake
- Preallocate the `subscriptions` slice when using an RSS-bridge,
  it's a good practise, and it might even marginally improve
  performances when adding __a lot__ of feeds via an rss-bridge instance, wooo!
This commit is contained in:
jvoisin 2024-02-26 17:07:28 +01:00 committed by Frédéric Guillot
parent ecd59009fb
commit 5b2558bf92

View file

@ -235,14 +235,15 @@ func (f *SubscriptionFinder) FindSubscriptionsFromWellKnownURLs(websiteURL strin
defer responseHandler.Close() defer responseHandler.Close()
if localizedError := responseHandler.LocalizedError(); localizedError != nil { if localizedError := responseHandler.LocalizedError(); localizedError != nil {
slog.Debug("Unable to subscribe", slog.String("fullURL", fullURL), slog.Any("error", localizedError.Error()))
continue continue
} }
subscription := new(Subscription) subscriptions = append(subscriptions, &Subscription{
subscription.Type = kind Type: kind,
subscription.Title = fullURL Title: fullURL,
subscription.URL = fullURL URL: fullURL,
subscriptions = append(subscriptions, subscription) })
} }
} }
@ -270,7 +271,7 @@ func (f *SubscriptionFinder) FindSubscriptionsFromRSSBridge(websiteURL, rssBridg
return nil, nil return nil, nil
} }
var subscriptions Subscriptions subscriptions := make(Subscriptions, 0, len(bridges))
for _, bridge := range bridges { for _, bridge := range bridges {
subscriptions = append(subscriptions, &Subscription{ subscriptions = append(subscriptions, &Subscription{
Title: bridge.BridgeMeta.Name, Title: bridge.BridgeMeta.Name,