// Session-communication scheduler config. Reuses the shared AWS scheduler target/role env
// (same EventBridge → SQS event queue as join-link); retry policy comes from constants.
import { SESSION_COMMUNICATION_SCHEDULER } from '../constants/session-communication-scheduler.constants';

/** Target queue ARN + execution role + group (env); retry policy (constants). */
export const getSessionCommunicationSchedulerConfig = () => ({
  targetQueueArn: process.env.AWS_SCHEDULER_TARGET_QUEUE_ARN,
  executionRoleArn: process.env.AWS_SCHEDULER_EXECUTION_ROLE_ARN,
  groupName: process.env.AWS_SCHEDULER_GROUP_NAME || undefined,
  maxRetryAttempts: SESSION_COMMUNICATION_SCHEDULER.MAX_RETRY_ATTEMPTS,
  maxEventAgeSeconds: SESSION_COMMUNICATION_SCHEDULER.MAX_EVENT_AGE_SECONDS,
});

/** Feature flag; default false. */
export const isSessionCommunicationSchedulerEnabled = (): boolean =>
  process.env.ENABLE_SESSION_COMMUNICATION_SCHEDULER?.toLowerCase() === 'true';
