function consentChanges({ aiGranted, recordingGranted, policyVersion, actorId, now = new Date() }) {
  return {
    ai_processing_consent_granted: aiGranted,
    ai_processing_consent_at: aiGranted ? now : null,
    ai_processing_consent_policy_version: aiGranted ? policyVersion : null,
    recording_consent_granted: recordingGranted,
    recording_consent_at: recordingGranted ? now : null,
    recording_consent_policy_version: recordingGranted ? policyVersion : null,
    consent_withdrawn_at: !aiGranted || !recordingGranted ? now : null,
    consent_updated_by_id: actorId,
    updatedById: actorId,
  };
}

module.exports = { consentChanges };
