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
|
- [x] NIP-05: Mapping Nostr keys to DNS-based internet identifiers
|
||||||
- [ ] NIP-06: Basic key derivation from mnemonic seed phrase
|
- [ ] NIP-06: Basic key derivation from mnemonic seed phrase
|
||||||
- [x] NIP-07: `window.nostr` capability for web browsers
|
- [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-09: Event Deletion
|
||||||
- [x] NIP-10: Conventions for clients' use of `e` and `p` tags in text events
|
- [x] NIP-10: Conventions for clients' use of `e` and `p` tags in text events
|
||||||
- [ ] NIP-11: Relay Information Document
|
- [ ] NIP-11: Relay Information Document
|
||||||
|
@ -54,14 +54,25 @@ export default function useEventPublisher() {
|
|||||||
return match
|
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 replaceHashtag = (match: string) => {
|
||||||
const tag = match.slice(1);
|
const tag = match.slice(1);
|
||||||
const idx = ev.Tags.length;
|
const idx = ev.Tags.length;
|
||||||
ev.Tags.push(new Tag(["t", tag.toLowerCase()], idx));
|
ev.Tags.push(new Tag(["t", tag.toLowerCase()], idx));
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
let content = msg.replace(/@npub[a-z0-9]+/g, replaceNpub);
|
const content = msg.replace(/@npub[a-z0-9]+/g, replaceNpub)
|
||||||
content = content.replace(HashtagRegex, replaceHashtag);
|
.replace(/note[a-z0-9]+/g, replaceNoteId)
|
||||||
|
.replace(HashtagRegex, replaceHashtag);
|
||||||
ev.Content = content;
|
ev.Content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user