feat: add enhanced support for kind:1111 comments

This commit is contained in:
codytseng
2025-05-24 16:26:28 +08:00
parent 78725d1e88
commit 06f9ea984f
6 changed files with 97 additions and 258 deletions

View File

@@ -177,11 +177,12 @@ export async function createCommentDraftEvent(
const {
quoteEventIds,
rootEventId,
rootEventKind,
rootEventPubkey,
rootKind,
rootPubkey,
rootUrl,
parentEventId,
parentEventKind,
parentEventPubkey
parentKind,
parentPubkey
} = await extractCommentMentions(content, parentEvent)
const hashtags = extractHashtags(content)
@@ -194,17 +195,29 @@ export async function createCommentDraftEvent(
tags.push(...generateImetaTags(images))
}
tags.push(
...mentions.filter((pubkey) => pubkey !== parentEventPubkey).map((pubkey) => ['p', pubkey])
)
tags.push(...mentions.filter((pubkey) => pubkey !== parentPubkey).map((pubkey) => ['p', pubkey]))
if (rootEventId) {
tags.push(
rootPubkey
? ['E', rootEventId, client.getEventHint(rootEventId), rootPubkey]
: ['E', rootEventId, client.getEventHint(rootEventId)]
)
}
if (rootPubkey) {
tags.push(['P', rootPubkey])
}
if (rootKind) {
tags.push(['K', rootKind.toString()])
}
if (rootUrl) {
tags.push(['I', rootUrl])
}
tags.push(
...[
['E', rootEventId, client.getEventHint(rootEventId), rootEventPubkey],
['K', rootEventKind.toString()],
['P', rootEventPubkey],
['e', parentEventId, client.getEventHint(parentEventId), parentEventPubkey],
['k', parentEventKind.toString()],
['p', parentEventPubkey]
['e', parentEventId, client.getEventHint(parentEventId), parentPubkey],
['k', parentKind.toString()],
['p', parentPubkey]
]
)