Align milestone charts and self-share flow
This commit is contained in:
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user