feat: note mentions
This commit is contained in:
parent
cecd8ba586
commit
002082d345
@ -10,7 +10,7 @@ Snort supports the following NIP's
|
||||
- [x] NIP-05: Mapping Nostr keys to DNS-based internet identifiers
|
||||
- [ ] NIP-06: Basic key derivation from mnemonic seed phrase
|
||||
- [x] NIP-07: `window.nostr` capability for web browsers
|
||||
- [ ] NIP-08: Handling Mentions
|
||||
- [x] NIP-08: Handling Mentions
|
||||
- [x] NIP-09: Event Deletion
|
||||
- [x] NIP-10: Conventions for clients' use of `e` and `p` tags in text events
|
||||
- [ ] NIP-11: Relay Information Document
|
||||
|
@ -54,14 +54,25 @@ export default function useEventPublisher() {
|
||||
return match
|
||||
}
|
||||
}
|
||||
const replaceNoteId = (match: string) => {
|
||||
try {
|
||||
const hex = bech32ToHex(match);
|
||||
const idx = ev.Tags.length;
|
||||
ev.Tags.push(new Tag(["e", hex], idx));
|
||||
return `#[${idx}]`
|
||||
} catch (error) {
|
||||
return match
|
||||
}
|
||||
}
|
||||
const replaceHashtag = (match: string) => {
|
||||
const tag = match.slice(1);
|
||||
const idx = ev.Tags.length;
|
||||
ev.Tags.push(new Tag(["t", tag.toLowerCase()], idx));
|
||||
return match;
|
||||
}
|
||||
let content = msg.replace(/@npub[a-z0-9]+/g, replaceNpub);
|
||||
content = content.replace(HashtagRegex, replaceHashtag);
|
||||
const content = msg.replace(/@npub[a-z0-9]+/g, replaceNpub)
|
||||
.replace(/note[a-z0-9]+/g, replaceNoteId)
|
||||
.replace(HashtagRegex, replaceHashtag);
|
||||
ev.Content = content;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user