Align milestone charts and self-share flow

This commit is contained in:
2026-08-14 13:04:09 +02:00
parent aa3b4d02ab
commit 8e34f97afb
4 changed files with 25 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
import { randomUUID } from 'crypto';
import { randomBytes } from 'crypto';
import { NextRequest, NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { csrfProtection } from '@/lib/csrf';
@@ -78,7 +78,9 @@ export async function PATCH(request: NextRequest, { params }: { params: { id: st
const now = new Date();
if (body.action === 'self_share') {
const token = milestone.shareToken || randomUUID().replace(/-/g, '');
// 72 random bits keep public URLs unguessable while making the share URL
// much less disruptive in an X compose window than a full UUID.
const token = milestone.shareToken || randomBytes(9).toString('base64url');
const updated = await db.socialMilestone.update({
where: { id: milestone.id },
data: { selfSharedAt: now, publicShareApprovedAt: now, shareToken: token, cardData: card, language },