From 5d486170dff46ccca6ce8a629b5434c5d9a57acc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 04:35:25 +0000 Subject: [PATCH 1/2] Initial plan From 127525cb451d06616e959b1857f81cb4d1305fe4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 04:42:19 +0000 Subject: [PATCH 2/2] Generate embed_key at project creation time in publish_handler - Added embed_key generation in INSERT statement using encode(gen_random_bytes(24), 'base64') - Ensures VIP links are immediately available after project publishing - Lazy generation in get_project handler still works as fallback for migrated projects Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com> --- server/src/handlers/project.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/handlers/project.rs b/server/src/handlers/project.rs index 83092c9..d31d761 100644 --- a/server/src/handlers/project.rs +++ b/server/src/handlers/project.rs @@ -183,9 +183,10 @@ pub async fn publish_handler( // 6. Update Database with new embed_token logic // gen_random_uuid() requires Postgres 13+. If older, ensure pgcrypto extension is enabled. + // Generate embed_key at creation time to ensure VIP links work immediately sqlx::query(" - INSERT INTO projects (slug, image_tag, markdown, owner_id, owner_username, shell, embed_token) - VALUES ($1, $2, $3, $4, $5, $6, gen_random_uuid()::text) + INSERT INTO projects (slug, image_tag, markdown, owner_id, owner_username, shell, embed_token, embed_key) + VALUES ($1, $2, $3, $4, $5, $6, gen_random_uuid()::text, encode(gen_random_bytes(24), 'base64')) ON CONFLICT (owner_username, slug) DO UPDATE SET image_tag = $2, markdown = $3, shell = $6 ")