Skip to content

Commit

Permalink
Make fetching more reliable.
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinGeekDev committed Feb 27, 2025
1 parent 6f77f16 commit 47763e0
Showing 1 changed file with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,18 @@ class FeedFetcher(private val httpClient: HttpClient, private val feedParser: Fe
nostrService: NostrService
): FeedFetchResult {
val authorInfoEvent =
nostrService.getMetadataFor(
profileHex = profilePubKey,
preferredRelays = profileRelays.ifEmpty { DEFAULT_FETCH_RELAYS }
)
try {
nostrService.getMetadataFor(
profileHex = profilePubKey,
preferredRelays = profileRelays.ifEmpty { DEFAULT_FETCH_RELAYS }
)
} catch (e: Exception) {
Logger.e("NostrFetcher", e)
nostrService.getMetadataFor(
profileHex = profilePubKey,
preferredRelays = DEFAULT_FETCH_RELAYS
)
}

if (authorInfoEvent.content.isBlank()) {
return FeedFetchResult.Error(
Expand All @@ -241,12 +249,20 @@ class FeedFetcher(private val httpClient: HttpClient, private val feedParser: Fe
}

val userPublishRelays =
nostrService
.fetchRelayListFor(
try {
nostrService
.fetchRelayListFor(
profileHex = profilePubKey,
fetchRelays = profileRelays.ifEmpty { DEFAULT_METADATA_RELAYS }
)
.filter { relay -> relay.writePolicy }
} catch (e: Exception) {
Logger.e("NostrFetcher", e)
nostrService.fetchRelayListFor(
profileHex = profilePubKey,
fetchRelays = profileRelays.ifEmpty { DEFAULT_METADATA_RELAYS }
fetchRelays = DEFAULT_METADATA_RELAYS
)
.filter { relay -> relay.writePolicy }
}

val userArticlesRequest =
RequestMessage.singleFilterRequest(
Expand Down

0 comments on commit 47763e0

Please sign in to comment.