diff options
Diffstat (limited to 'fetchers/app.bsky.feed.go')
| -rw-r--r-- | fetchers/app.bsky.feed.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/fetchers/app.bsky.feed.go b/fetchers/app.bsky.feed.go index a0eaeb2..232d020 100644 --- a/fetchers/app.bsky.feed.go +++ b/fetchers/app.bsky.feed.go @@ -57,6 +57,7 @@ func FetchAppBskyFeedPostsWithCursor(conf *Config, did, pdsURL string, session * } else { notes, err := parseAppBskyFeedPostCollection(conf, session, records, author) conf.Cache.SetCursor(did, nextCursor) + updatePostCount(conf, did, cursor, len(notes)) return notes, err } } @@ -69,9 +70,18 @@ func FetchAppBskyFeedPostsWithCursor(conf *Config, did, pdsURL string, session * notes, err := parseAppBskyFeedPostCollection(conf, session, records, author) conf.Cache.SetCursor(did, nextCursor) + updatePostCount(conf, did, cursor, len(notes)) return notes, err } +func updatePostCount(conf *Config, did, cursor string, fetchedCount int) { + if cursor == "" { + conf.Cache.SetPostCount(did, fetchedCount) + } else { + conf.Cache.AddPostCount(did, fetchedCount) + } +} + func GetAppBskyFeedPostByURI(conf *Config, uri string, session *auth.OAuthState) (*notes.Note, error) { // check cache, return if it was cached without auth or if it was cached with auth and we have auth conf.Logger.Debug("Getting app.bsky.feed.post", "uri", uri) @@ -81,7 +91,8 @@ func GetAppBskyFeedPostByURI(conf *Config, uri string, session *auth.OAuthState) return cached, nil } - // author requires auth - if we have a session, serve it + // author requires auth + // if we have a session, serve it // if the token was invalid, trust that it would have been caught by the "refresh token" call in main if session != nil { return cached, nil |
