-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add support for arbitrary single-letter tags in Filter #154
Conversation
ad9eae2
to
30ca55c
Compare
Sources/NostrSDK/Filter.swift
Outdated
public let pubkeys: [String]? | ||
|
||
|
||
/// a list of tag values that are referenced by single English-alphabet letter tag names |
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.
/// a list of tag values that are referenced by single English-alphabet letter tag names | |
/// a list of tag values that are referenced by single Latin-script letter tag names |
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.
Changed it to "basic Latin letter" instead.
https://en.wikipedia.org/wiki/ISO_basic_Latin_alphabet
|
||
var intValue: Int? { nil } | ||
|
||
init?(intValue: Int) { |
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.
What's the purpose of an initializer that always returns nil?
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.
Its declaration is required by the CodingKey
protocol. The compiler doesn't like it if it's not there. Per the documentation of this initializer, it says
/// Creates a new instance from the specified integer.
///
/// If the value passed as `intValue` does not correspond to any instance of
/// this type, the result is `nil`.
///
/// - parameter intValue: The integer value of the desired key.
init?(intValue: Int)
Sources/NostrSDK/Filter.swift
Outdated
@@ -54,19 +63,85 @@ public struct Filter: Codable, Hashable, Equatable { | |||
/// - kinds: a list of a kind numbers | |||
/// - events: a list of event ids that are referenced in an "e" tag | |||
/// - pubkeys: a list of pubkeys that are referenced in a "p" tag | |||
/// - tags: a list of tag values that are referenced by single English-alphabet letter tag names |
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.
/// - tags: a list of tag values that are referenced by single English-alphabet letter tag names | |
/// - tags: a list of tag values that are referenced by single Latin-script letter tag names |
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.
Changed it to "basic Latin letter" instead.
https://en.wikipedia.org/wiki/ISO_basic_Latin_alphabet
Sources/NostrSDK/Filter.swift
Outdated
/// If `tags` contains an `e` tag and `events` is also provided, `events` takes precedence. | ||
/// If `tags` contains a `p` tag and `pubkeys` is also provided, `pubkeys` takes precedence. | ||
/// | ||
/// Returns `nil` if `tags` contains tag names that are not in the English-alphabet of A-Z or a-z. |
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.
/// Returns `nil` if `tags` contains tag names that are not in the English-alphabet of A-Z or a-z. | |
/// Returns `nil` if `tags` contains tag names that are not in the Latin script of A-Z or a-z. |
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.
Changed it to "basic Latin letter" instead.
https://en.wikipedia.org/wiki/ISO_basic_Latin_alphabet
Sources/NostrSDK/Filter.swift
Outdated
} | ||
|
||
private extension Character { | ||
var isEnglishLetter: Bool { |
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.
IMO we should generally use "Latin script" or "Latin alphabet" rather than "English letter" because it is more accurate. There are many languages that use the Latin alphabet of A-Z.
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.
I think "Latin script" might be too broad.
The Latin script is the basis of the International Phonetic Alphabet, and the 26 most widespread letters are the letters contained in the ISO basic Latin alphabet, which are the same letters as the English alphabet.
Maybe isBasicLatinLetter
is better. I chose Letter
over Alphabet
or Script
because Swift already has an isLetter
property, so making the naming consistent to that makes more sense.
Co-authored-by: Bryan Montz <[email protected]>
…than English alphabet
@tyiu Feel free to merge this one after resolving conflicts. |
https://github.com/nostr-protocol/nips/blob/4fa65b81cede9eaf8375d4f92bc80cf298190e0c/01.md#from-client-to-relay-sending-events-and-creating-subscriptions