diff --git a/src/lib/components/ZettelEditor.svelte b/src/lib/components/ZettelEditor.svelte index 5bac793..fe545cd 100644 --- a/src/lib/components/ZettelEditor.svelte +++ b/src/lib/components/ZettelEditor.svelte @@ -185,29 +185,6 @@ Understanding the nature of knowledge itself... {/if} - -
- {#if generatedEvents && contentType !== 'none'} - - {:else} -
- Add content to enable publishing -
- {/if} -
@@ -227,6 +204,28 @@ Understanding the nature of knowledge itself... Show Preview {/if} + + + {#if generatedEvents && contentType !== 'none'} + + {:else} +
+ Add content to enable publishing +
+ {/if}
diff --git a/src/lib/services/publisher.ts b/src/lib/services/publisher.ts index ad2831a..5d58923 100644 --- a/src/lib/services/publisher.ts +++ b/src/lib/services/publisher.ts @@ -143,11 +143,28 @@ export async function publishSingleEvent( return tag; }); + // Auto-add author identity if not publishing on behalf of others + const hasAuthorTag = fixedTags.some(tag => tag[0] === 'author'); + const hasPTag = fixedTags.some(tag => tag[0] === 'p'); + + const finalTags = [...fixedTags]; + + if (!hasAuthorTag && ndk.activeUser) { + // Add display name as author + const displayName = ndk.activeUser.profile?.displayName || ndk.activeUser.profile?.name || 'Anonymous'; + finalTags.push(['author', displayName]); + } + + if (!hasPTag && ndk.activeUser) { + // Add pubkey as p-tag + finalTags.push(['p', ndk.activeUser.pubkey]); + } + // Create and sign NDK event const ndkEvent = new NDKEvent(ndk); ndkEvent.kind = kind; ndkEvent.created_at = Math.floor(Date.now() / 1000); - ndkEvent.tags = fixedTags; + ndkEvent.tags = finalTags; ndkEvent.content = content; ndkEvent.pubkey = ndk.activeUser.pubkey;