aboutsummaryrefslogtreecommitdiff
path: root/backend/fetchers/app.bsky.actor.go
diff options
context:
space:
mode:
authorGuillermo Serrahima <dev@vylion.com>2026-04-07 08:36:13 +0200
committerGuillermo Serrahima <dev@vylion.com>2026-04-07 08:46:41 +0200
commit1a31555761bb5180ed496d61511f6a36d791cb78 (patch)
treecc14aa03002734feb9e6c59a3ee02ab652b1764d /backend/fetchers/app.bsky.actor.go
parent2bd2e1fd4fcf147ff4bb229226d879b6b6b5fa78 (diff)
downloadllostre-1a31555761bb5180ed496d61511f6a36d791cb78.tar.xz
llostre-1a31555761bb5180ed496d61511f6a36d791cb78.zip
reworked cache with redis + improved fetching
Diffstat (limited to 'backend/fetchers/app.bsky.actor.go')
-rw-r--r--backend/fetchers/app.bsky.actor.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/backend/fetchers/app.bsky.actor.go b/backend/fetchers/app.bsky.actor.go
index 0752223..a56fe0b 100644
--- a/backend/fetchers/app.bsky.actor.go
+++ b/backend/fetchers/app.bsky.actor.go
@@ -11,6 +11,7 @@ import (
"net"
"net/http"
"strings"
+ "time"
)
type DIDDocument struct {
@@ -136,12 +137,13 @@ func FetchAppBskyActorProfile(logger *slog.Logger, did, pdsURL, slingshotURL str
uri := fmt.Sprintf("at://%s/app.bsky.actor.profile/self", did)
// try slingshot first
- if slingshotURL != "" {
+ if slingshotURL != "" && general.SlingshotAvailable() {
rawRecord, err := general.FetchRawRecordByURI(logger, uri, slingshotURL, session)
if err != nil {
logger.Warn("slingshot profile fetch failed", "did", did, "error", err)
+ general.SetSlingshotBackoff(5 * time.Minute)
} else {
- return parseAppBskyActorProfile(did, rawRecord, cache)
+ return parseAppBskyActorProfile(did, pdsURL, rawRecord, cache)
}
}
@@ -151,7 +153,7 @@ func FetchAppBskyActorProfile(logger *slog.Logger, did, pdsURL, slingshotURL str
return nil, err
}
- return parseAppBskyActorProfile(did, rawRecord, cache)
+ return parseAppBskyActorProfile(did, pdsURL, rawRecord, cache)
}
func FetchAppBskyActorProfiles(logger *slog.Logger, dids []string, pdsURL, slingshotURL string, session *auth.OAuthState, cache *Cache) map[string]notes.Author {
@@ -165,7 +167,7 @@ func FetchAppBskyActorProfiles(logger *slog.Logger, dids []string, pdsURL, sling
return authors
}
-func parseAppBskyActorProfile(did string, rawRecord *general.RawRecord, cache *Cache) (*notes.Author, error) {
+func parseAppBskyActorProfile(did, pds string, rawRecord *general.RawRecord, cache *Cache) (*notes.Author, error) {
var profile notes.AppBskyActorProfileRecord
if err := json.Unmarshal(rawRecord.Value, &profile); err != nil {
return nil, err
@@ -176,7 +178,7 @@ func parseAppBskyActorProfile(did string, rawRecord *general.RawRecord, cache *C
handle = "handle.invalid"
}
- author, err := notes.AuthorFromAppBskyActorProfileRecord(profile, did, handle)
+ author, err := notes.AuthorFromAppBskyActorProfileRecord(profile, did, handle, pds)
cache.SetAuthor(did, author)
return author, nil