fix: allow generating review link for pre-existing posts
All checks were successful
Deploy / deploy (push) Successful in 12s
All checks were successful
Deploy / deploy (push) Successful in 12s
Show button only when post has no approval token. Once a link exists, only the link is shown. Server preserves status for non-draft posts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1480,14 +1480,18 @@ app.post('/api/posts/:id/submit-review', requireAuth, requireOwnerOrRole('posts'
|
||||
const expiresAt = new Date();
|
||||
expiresAt.setDate(expiresAt.getDate() + DEFAULTS.tokenExpiryDays);
|
||||
|
||||
await nocodb.update('Posts', req.params.id, {
|
||||
status: 'in_review',
|
||||
const updateData = {
|
||||
approval_token: token,
|
||||
token_expires_at: expiresAt.toISOString(),
|
||||
approved_by_name: null,
|
||||
approved_at: null,
|
||||
feedback: null,
|
||||
});
|
||||
};
|
||||
// Only change status to in_review for draft/rejected posts
|
||||
if (!existing.status || existing.status === 'draft' || existing.status === 'rejected') {
|
||||
updateData.status = 'in_review';
|
||||
updateData.approved_by_name = null;
|
||||
updateData.approved_at = null;
|
||||
updateData.feedback = null;
|
||||
}
|
||||
await nocodb.update('Posts', req.params.id, updateData);
|
||||
|
||||
const reviewUrl = `${req.protocol}://${req.get('host')}/review-post/${token}`;
|
||||
res.json({ success: true, token, reviewUrl, expiresAt: expiresAt.toISOString() });
|
||||
|
||||
Reference in New Issue
Block a user