mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 19:28:25 +00:00
fix(dm): convert @npub mentions to nostr: URIs in NIP-17 messages
The NIP-17 DM composer sent the typed text verbatim, so an `@npub1…` mention went out as plain text instead of a `nostr:nprofile1…` reference. Run the message through NewMessageTagger like every other composer, but use only the rewritten content: its pTags are not added to the event, because a NIP-17 room is defined by its p-tags and tagging a mentioned user would move the message into a different conversation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019JSYZ3DdZJXvv4vh4vw4G9
This commit is contained in:
+11
@@ -209,4 +209,15 @@ class NewMessageTaggerKeyParseTest {
|
||||
|
||||
assertTrue(tagger.message.startsWith("hi nostr:nprofile1"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun possessiveAtMentionBecomesNostrUri() =
|
||||
runBlocking {
|
||||
val npub = "npub19ma2w9dmk3kat0nt0k5dwuqzvmg3va9ezwup0zkakhpwv0vcwvcsg8axkl"
|
||||
val tagger = NewMessageTagger(message = "@$npub's ERP screens look good", dao = dao)
|
||||
tagger.run()
|
||||
|
||||
val nprofile = tagger.pTags!!.single().toNProfile()
|
||||
assertEquals("nostr:$nprofile's ERP screens look good", tagger.message)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -603,7 +603,13 @@ class ChatNewMessageViewModel :
|
||||
) {
|
||||
val room = room.value ?: return
|
||||
|
||||
val messageText = message.text.toString()
|
||||
// Rewrites typed `@npub…`/`note1…` references into `nostr:` URIs. Only the rewritten text is
|
||||
// used: the tagger's pTags must NOT reach the event, since a NIP-17 room is defined by its
|
||||
// p-tags — adding a mentioned user would send the message to a different conversation.
|
||||
val tagger = NewMessageTagger(message.text.toString(), null, null, accountViewModel)
|
||||
tagger.run()
|
||||
|
||||
val messageText = tagger.message
|
||||
val urls = findURLs(messageText)
|
||||
val usedAttachments = iMetaAttachments.filterIsIn(urls.toSet())
|
||||
val emojis = accountViewModel.account.emoji.findEmojiTags(messageText)
|
||||
|
||||
Reference in New Issue
Block a user