Add a "client" tag to all published events

This commit is contained in:
Alex Gleason 2025-05-16 12:28:01 -05:00
parent 70eceef6ae
commit cc3d87192c
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

View File

@ -17,12 +17,21 @@ export function useNostrPublish() {
return useMutation({ return useMutation({
mutationFn: async (t: EventTemplate) => { mutationFn: async (t: EventTemplate) => {
if (user) { 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({ const event = await user.signer.signEvent({
kind: t.kind, kind: t.kind,
content: t.content ?? "", content: t.content ?? "",
tags: t.tags ?? [], tags,
created_at: t.created_at ?? Math.floor(Date.now() / 1000), created_at: t.created_at ?? Math.floor(Date.now() / 1000),
}); });
await nostr.event(event, { signal: AbortSignal.timeout(5000) }); await nostr.event(event, { signal: AbortSignal.timeout(5000) });
} else { } else {
throw new Error("User is not logged in"); throw new Error("User is not logged in");