feat: add option to add client tag

This commit is contained in:
codytseng
2024-12-24 12:13:39 +08:00
parent 234319ef50
commit 31f70c2ab1
8 changed files with 117 additions and 12 deletions

View File

@@ -39,10 +39,13 @@ export function createRepostDraftEvent(event: Event): TDraftEvent {
export async function createShortTextNoteDraftEvent(
content: string,
parentEvent?: Event
options: {
parentEvent?: Event
addClientTag?: boolean
} = {}
): Promise<TDraftEvent> {
const { pubkeys, otherRelatedEventIds, quoteEventIds, rootEventId, parentEventId } =
await extractMentions(content, parentEvent)
await extractMentions(content, options.parentEvent)
const hashtags = extractHashtags(content)
const tags = pubkeys
@@ -50,7 +53,6 @@ export async function createShortTextNoteDraftEvent(
.concat(otherRelatedEventIds.map((eventId) => ['e', eventId]))
.concat(quoteEventIds.map((eventId) => ['q', eventId]))
.concat(hashtags.map((hashtag) => ['t', hashtag]))
.concat([['client', 'jumble']])
if (rootEventId) {
tags.push(['e', rootEventId, '', 'root'])
@@ -60,6 +62,10 @@ export async function createShortTextNoteDraftEvent(
tags.push(['e', parentEventId, '', 'reply'])
}
if (options.addClientTag) {
tags.push(['client', 'jumble'])
}
return {
kind: kinds.ShortTextNote,
content,