-
Notifications
You must be signed in to change notification settings - Fork 297
feat: add purplepag.es as profile-only relay #3459
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,11 +33,28 @@ enum NostrRequestType { | |
| guard case .typical(let req) = self else { | ||
| return true | ||
| } | ||
|
|
||
| return req.is_read | ||
| } | ||
| } | ||
|
|
||
| extension NostrRequestType { | ||
| /// Profile-related kinds that should be queried on profiles-only relays | ||
| static let profileKinds: Set<NostrKind> = [.metadata, .contacts, .relay_list] | ||
|
|
||
| /// Whether this request is for profile-related data only | ||
| var isProfileRelated: Bool { | ||
| guard case .typical(let req) = self else { return false } | ||
| guard case .subscribe(let sub) = req else { return false } | ||
|
|
||
| // Check if ALL filters contain ONLY profile-related kinds | ||
| return sub.filters.allSatisfy { filter in | ||
| guard let kinds = filter.kinds else { return false } // No kinds specified = could be anything | ||
| return kinds.allSatisfy { Self.profileKinds.contains($0) } | ||
| } | ||
| } | ||
|
Comment on lines
+46
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against edge cases with empty filter or kinds arrays. The
These edge cases could cause non-profile queries to be sent to purplepag.es, defeating the purpose of this filtering. 🔎 Proposed fix to handle edge cases /// Whether this request is for profile-related data only
var isProfileRelated: Bool {
guard case .typical(let req) = self else { return false }
guard case .subscribe(let sub) = req else { return false }
-
+
+ // Must have at least one filter
+ guard !sub.filters.isEmpty else { return false }
+
// Check if ALL filters contain ONLY profile-related kinds
return sub.filters.allSatisfy { filter in
guard let kinds = filter.kinds else { return false } // No kinds specified = could be anything
+ guard !kinds.isEmpty else { return false } // Empty kinds = could be anything
return kinds.allSatisfy { Self.profileKinds.contains($0) }
}
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /// Models a standard request/message that is sent to a Nostr relay. | ||
| enum NostrRequest { | ||
| /// Subscribes to receive information from the relay | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential duplicate relay with conflicting variants.
If a user manually adds their NWC relay URL to their relay list, it will be created with variant
.regular(line 264). This code then appends the same URL again with variant.nwc. Whenapply()processes the list and callsfirst(where: { $0.url == url })(line 230), it will select the first descriptor with that URL—likely the.regularvariant—causing the NWC relay to be misconfigured.🔎 Proposed fix to prevent duplicate relay URLs
private func computeRelaysToConnectTo(with relayList: NIP65.RelayList) -> [RelayPool.RelayDescriptor] { var descriptors = relayList.toRelayDescriptors() if let nwcWallet = delegate.nwcWallet { - descriptors.append(.nwc(url: nwcWallet.relay)) + // Remove any existing descriptor with the NWC relay URL to avoid conflicts + descriptors.removeAll(where: { $0.url == nwcWallet.relay }) + descriptors.append(.nwc(url: nwcWallet.relay)) } return descriptors }📝 Committable suggestion
🤖 Prompt for AI Agents