mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 18:11:13 -05:00
feat: Implement comprehensive audit logging
This commit is contained in:
@@ -602,6 +602,35 @@ serve(async (req) => {
|
||||
console.error('[APPROVAL] Failed to update submission status:', { error: updateError.message });
|
||||
}
|
||||
|
||||
// Log audit trail for submission action
|
||||
try {
|
||||
const approvedCount = approvalResults.filter(r => r.success).length;
|
||||
const rejectedCount = approvalResults.filter(r => !r.success).length;
|
||||
|
||||
await supabaseClient.rpc('log_admin_action', {
|
||||
_admin_user_id: authenticatedUserId,
|
||||
_target_user_id: submission.user_id,
|
||||
_action: finalStatus === 'approved'
|
||||
? 'submission_approved'
|
||||
: finalStatus === 'partially_approved'
|
||||
? 'submission_partially_approved'
|
||||
: 'submission_rejected',
|
||||
_details: {
|
||||
submission_id: submissionId,
|
||||
submission_type: submission.submission_type,
|
||||
items_approved: approvedCount,
|
||||
items_rejected: rejectedCount,
|
||||
total_items: approvalResults.length,
|
||||
final_status: finalStatus,
|
||||
has_dependency_failure: hasDependencyFailure,
|
||||
reviewer_notes: reviewerNotes
|
||||
}
|
||||
});
|
||||
} catch (auditError) {
|
||||
// Log but don't fail the operation
|
||||
console.error('[AUDIT] Failed to log admin action:', auditError);
|
||||
}
|
||||
|
||||
const duration = endRequest(tracking);
|
||||
|
||||
return new Response(
|
||||
|
||||
Reference in New Issue
Block a user