mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 13:31:12 -05:00
feat: Implement comprehensive audit logging
This commit is contained in:
@@ -1155,6 +1155,13 @@ export async function escalateSubmission(
|
||||
throw new Error('User authentication required to escalate submission');
|
||||
}
|
||||
|
||||
// Fetch submission details for audit log
|
||||
const { data: submission } = await supabase
|
||||
.from('content_submissions')
|
||||
.select('user_id, submission_type')
|
||||
.eq('id', submissionId)
|
||||
.single();
|
||||
|
||||
const { error } = await supabase
|
||||
.from('content_submissions')
|
||||
.update({
|
||||
@@ -1166,4 +1173,22 @@ export async function escalateSubmission(
|
||||
.eq('id', submissionId);
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
// Log audit trail for escalation
|
||||
if (submission) {
|
||||
try {
|
||||
await supabase.rpc('log_admin_action', {
|
||||
_admin_user_id: userId,
|
||||
_target_user_id: submission.user_id,
|
||||
_action: 'submission_escalated',
|
||||
_details: {
|
||||
submission_id: submissionId,
|
||||
submission_type: submission.submission_type,
|
||||
escalation_reason: reason
|
||||
}
|
||||
});
|
||||
} catch (auditError) {
|
||||
logger.error('Failed to log escalation audit', { error: auditError });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user