From cc3d87192c8080b1339abd20214520c48e310509 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 16 May 2025 12:28:01 -0500 Subject: [PATCH] Add a "client" tag to all published events --- src/hooks/useNostrPublish.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hooks/useNostrPublish.ts b/src/hooks/useNostrPublish.ts index 204b6bc..a940385 100644 --- a/src/hooks/useNostrPublish.ts +++ b/src/hooks/useNostrPublish.ts @@ -17,12 +17,21 @@ export function useNostrPublish() { return useMutation({ mutationFn: async (t: EventTemplate) => { if (user) { + const tags = t.tags ?? []; + + // Add the client tag if it doesn't exist + if (!tags.some((tag) => tag[0] === "client")) { + // FIXME: Replace "mkstack" with the actual client name + tags.push(["client", "mkstack"]); + } + const event = await user.signer.signEvent({ kind: t.kind, content: t.content ?? "", - tags: t.tags ?? [], + tags, created_at: t.created_at ?? Math.floor(Date.now() / 1000), }); + await nostr.event(event, { signal: AbortSignal.timeout(5000) }); } else { throw new Error("User is not logged in");