feat: add moderation center for reports and ratings with user cleanup cron job
This commit is contained in:
@@ -46,7 +46,17 @@ export async function GET(
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json(ratings);
|
||||
// 3. Fallback for deleted users
|
||||
const formattedRatings = ratings.map(r => ({
|
||||
...r,
|
||||
user: r.user || {
|
||||
id: null,
|
||||
name: "Utilisateur supprimé",
|
||||
avatar: null
|
||||
}
|
||||
}));
|
||||
|
||||
return NextResponse.json(formattedRatings);
|
||||
|
||||
} catch (error: any) {
|
||||
console.error('Error fetching ratings:', error);
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function POST(
|
||||
}
|
||||
|
||||
// 2. Security: Only the owner of the business can reply
|
||||
if (rating.business.ownerId !== userId) {
|
||||
if (!rating.business || rating.business.ownerId !== userId) {
|
||||
return NextResponse.json({ error: 'Action non autorisée. Seul l\'entrepreneur concerné peut répondre.' }, { status: 403 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user