aboutsummaryrefslogtreecommitdiff
path: root/backend/fetchers/app.bsky.actor.go
diff options
context:
space:
mode:
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