Skip to content
New issue

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

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

Already on GitHub? # to your account

Refactor threaded event tag building and interpreting logic so non-kind-1 events can reuse them #186

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

tyiu
Copy link
Contributor

@tyiu tyiu commented Oct 18, 2024

For example, NIP-17 - Private Direct Message uses threading, so this PR unblocks that work from happening.

@tyiu tyiu force-pushed the tyiu/refactor-nip-10-tag-logic branch from 254d823 to d19febd Compare October 18, 2024 11:39
@@ -150,11 +150,160 @@ public struct EventTag: RelayProviding, RelayURLValidating, Equatable {
}
}

public protocol EventTagInterpreting: NostrEvent {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused.


// Add the author "p" tag if it was not already added.
if !tags.contains(where: { $0.name == TagName.pubkey.rawValue && $0.value == repliedEvent.pubkey }) {
if let validatedRelayURL {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific logic around adding a relay to the p-tag is new. Which is why TextNoteEventTests was updated to match the assertion. All the other logic here was copied from TextNoteEvent.

// NIP-10 states that the first event tag is the root.
return eventTags.first
/// Events mentioned in the note content.
@available(*, deprecated, message: "Deprecated in favor of referencedEventIds. Mention is an overloaded term from NIP-10.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIP-01 says

- The `e` tag, used to refer to an event: `["e", <32-bytes lowercase hex of the id of another event>, <recommended relay URL, optional>]`

Since this line uses the word refer, I've called the new property referencedEventIds.

@@ -36,88 +36,26 @@ public final class TextNoteEvent: NostrEvent, CustomEmojiInterpreting {
try super.init(kind: .textNote, content: content, tags: tags, createdAt: createdAt, signedBy: keypair)
}

/// Pubkeys mentioned in the note content.
/// Pubkeys referenced in the note content.
@available(*, deprecated, message: "Deprecated in favor of referencedPubkeys. Mention is an overloaded term from NIP-10.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIP-01 says

- The `p` tag, used to refer to another user: `["p", <32-bytes lowercase hex of a pubkey>, <recommended relay URL, optional>]`

Since this line uses the word refer, I've called the new property referencedPubkeys.

@tyiu tyiu merged commit 9ae3db2 into main Oct 18, 2024
5 checks passed
@tyiu tyiu deleted the tyiu/refactor-nip-10-tag-logic branch October 18, 2024 11:43
@tyiu tyiu mentioned this pull request Oct 19, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant