Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue where relay metadata is never updated #1472 #1473

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where nostr entities in URLs were treated like quoted note links.
- Added in-app profile photo editing.
- Changed "Name" to "Display Name" on the Edit Profile View.
- Fixed issue where relay metadata is never updated.

### Internal Changes
- Included the npub in the properties list sent to analytics.
Expand Down
3 changes: 2 additions & 1 deletion Nos/Service/Relay/RelayService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ extension RelayService {
}

private func queryRelayMetadataIfNeeded(_ relayAddress: URL) async throws {
let metadataMaxAge: TimeInterval = 86_400 * 3 // 3 days
let address = relayAddress.absoluteString
let shouldQueryRelayMetadata = try await backgroundContext.perform { [backgroundContext] in
guard let relay = try backgroundContext.fetch(Relay.relay(by: address)).first else {
Expand All @@ -809,7 +810,7 @@ extension RelayService {
guard let timestamp = relay.metadataFetchedAt else {
return true
}
return timestamp.timeIntervalSinceNow > 86_400 * 3 // 3 days
return Date.now.timeIntervalSince(timestamp) > metadataMaxAge
}
guard shouldQueryRelayMetadata else {
return
Expand Down
Loading