feat(feeds): queue explicit FreshRSS state changes with uncertain-outcome recovery
Build and publish container images / images (push) Failing after 12m40s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 05:51:47 +09:00
1 parent 16e572397b
commit 131a7ca01f
12 files changed
+973 -58

No files matched your search

+36 -15
View File
@@ -328,11 +328,11 @@ func feedRequest(ctx context.Context, client *http.Client, method, target, auth
}
return raw, res.Header, res.StatusCode, nil
}
func fetchFreshRSS(ctx context.Context, client *http.Client, v store.FeedSource, user, password string, catalogs ...*[]store.FeedRemoteSubscription) ([]store.FeedItem, error) {
func freshRSSLogin(ctx context.Context, client *http.Client, v store.FeedSource, user, password string) (string, error) {
base := strings.TrimRight(v.URL, "/")
raw, _, _, e := feedRequest(ctx, client, "POST", base+"/accounts/ClientLogin", "", url.Values{"Email": {user}, "Passwd": {password}}, nil)
if e != nil {
return nil, e
return "", e
}
auth := ""
for _, line := range strings.Split(string(raw), "\n") {
@@ -341,12 +341,38 @@ func fetchFreshRSS(ctx context.Context, client *http.Client, v store.FeedSource,
}
}
if auth == "" || len(auth) > 4096 || strings.ContainsAny(auth, "\r\n") {
return nil, errors.New("credentials")
return "", errors.New("credentials")
}
raw, _, _, e = feedRequest(ctx, client, "GET", base+"/reader/api/0/stream/contents/reading-list?output=json&n=200", auth, nil, nil)
return auth, nil
}
func fetchFreshRSS(ctx context.Context, client *http.Client, v store.FeedSource, user, password string, catalogs ...*[]store.FeedRemoteSubscription) ([]store.FeedItem, error) {
base := strings.TrimRight(v.URL, "/")
auth, e := freshRSSLogin(ctx, client, v, user, password)
if e != nil {
return nil, e
}
raw, _, _, e := feedRequest(ctx, client, "GET", base+"/reader/api/0/stream/contents/reading-list?output=json&n=200", auth, nil, nil)
if e != nil {
return nil, e
}
items, e := parseFreshRSSItems(raw, base)
if e != nil {
return nil, e
}
if len(catalogs) > 0 {
raw, _, _, e = feedRequest(ctx, client, "GET", base+"/reader/api/0/subscription/list?output=json", auth, nil, nil)
if e != nil {
return nil, e
}
catalog, e := parseFreshRSSCatalog(raw)
if e != nil {
return nil, e
}
*catalogs[0] = catalog
}
return items, nil
}
func parseFreshRSSItems(raw []byte, base string) ([]store.FeedItem, error) {
var response struct {
Items []struct {
ID string `json:"id"`
@@ -411,17 +437,6 @@ func fetchFreshRSS(ctx context.Context, client *http.Client, v store.FeedSource,
}
out = append(out, item)
}
if len(catalogs) > 0 {
raw, _, _, e = feedRequest(ctx, client, "GET", base+"/reader/api/0/subscription/list?output=json", auth, nil, nil)
if e != nil {
return nil, e
}
catalog, e := parseFreshRSSCatalog(raw)
if e != nil {
return nil, e
}
*catalogs[0] = catalog
}
return out, nil
}
@@ -465,6 +480,9 @@ func (s *Server) syncFeedSources(ctx context.Context, job *store.EventJob) error
func (s *Server) syncFeedSourcesWithClient(ctx context.Context, job *store.EventJob, client *http.Client) error {
ctx, cancel := context.WithTimeout(ctx, 35*time.Second)
defer cancel()
if e := s.syncFeedActions(ctx, client); e != nil {
return e
}
sources, e := s.store.DueFeedSources(ctx)
if e != nil {
return e
@@ -474,6 +492,9 @@ func (s *Server) syncFeedSourcesWithClient(ctx context.Context, job *store.Event
if ctx.Err() != nil {
break
}
if deadline, ok := ctx.Deadline(); ok && time.Until(deadline) < 9*time.Second {
break
}
if !s.systemExtensionEnabled(v.Domain, "organizer.feeds") {
continue
}