-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
nostr: add nip22::extract_root
and nip22:extract_parent
#729
base: master
Are you sure you want to change the base?
Conversation
79a3855
to
a436e44
Compare
nip22::extract_root_data
and nip22:extract_parent_data
nip22::extract_root
and nip22:extract_parent
Closes #677 Signed-off-by: Yuki Kishimoto <[email protected]>
/// Kind | ||
/// | ||
/// This isn't properly defined yet but it will surely be needed in the future. It could i.e. be a root domain | ||
kind: Option<&'a Kind>, |
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.
either remove External::kind
because it's not used and not defined yet, or change it's type from Kind
to String
. The Kind
enum is not useful for external things
} | ||
|
||
let kind: Option<&Kind> = extract_kind(event, is_root); | ||
let pubkey_hint: Option<&PublicKey> = extract_public_key(event, is_root); |
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.
The pubkey hint is not a p-tag, it's the item after the relay hint:
["e", "event-id", "relay-hint", "pubkey-hint"],
doesn't apply to i
and a
, only e
} | ||
|
||
fn extract_kind(event: &Event, is_root: bool) -> Option<&Kind> { | ||
let tag = event.tags.find_standardized(TagKind::k())?; |
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.
This will always consider only the first k|K tag, right? But Comments can have a k and a K tag at the same time.
So you should use filter_standardized
then find the first uppercase or lowercase tag depending on is_root
. Or whatever way is best to achieve this
} | ||
} | ||
|
||
fn extract_event(event: &Event, is_root: bool) -> Option<(&EventId, Option<&RelayUrl>)> { |
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.
Return value is missing the Option<PublicKey>
pubkey hint
} | ||
|
||
fn extract_coordinate(event: &Event, is_root: bool) -> Option<(&Coordinate, Option<&RelayUrl>)> { | ||
let tag = event.tags.find_standardized(TagKind::a())?; |
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.
Same here. Comments can have an A
and an a
tag at the same time.
} | ||
|
||
fn extract_external(event: &Event, is_root: bool) -> Option<(&ExternalContentId, Option<&Url>)> { | ||
let tag = event.tags.find_standardized(TagKind::i())?; |
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.
Same here. Comments can have an I
and an i
tag at the same time.
@dluvian