# ============================================
# SOCIAL MEDIA MANAGER - APPLICATION CONFIG
# ============================================

# ============================================
# SERVER CONFIGURATION
# ============================================
server:
  port: ${SERVER_PORT:8000}
  servlet:
    encoding:
      charset: UTF-8
      enabled: true
      force: true

spring:
  application:
    name: social-media-manager    
  # ============================================
  # DATABASE CONFIGURATION - PostgreSQL 17
  # ============================================
  datasource:
    url: ${DATABASE_URL:jdbc:postgresql://162.240.175.216:5432/wwinst_social_media_manager_prd}
    username: ${DATABASE_USERNAME:wwinst_root}
    password: ${DATABASE_PASSWORD:Adorigram190120!}
    driver-class-name: org.postgresql.Driver
    hikari:
      maximum-pool-size: ${DB_POOL_SIZE:20}
      minimum-idle: ${DB_POOL_MIN_IDLE:5}
      connection-timeout: 20000
      
  jpa:
    hibernate:
      ddl-auto: update
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
        implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
    show-sql: ${SHOW_SQL:false}
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        "[format_sql]": true
        "[default_schema]": core_business
      
  # ============================================
  # SECURITY CONFIGURATION
  # ============================================
  security:
    oauth2:
      client:
        registration:
          instagram:
            client-id: ${INSTAGRAM_CLIENT_ID:}
            client-secret: ${INSTAGRAM_CLIENT_SECRET:}
            authorization-grant-type: authorization_code
            redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
            scope: user_profile,user_media
          facebook:
            client-id: ${FACEBOOK_CLIENT_ID:}
            client-secret: ${FACEBOOK_CLIENT_SECRET:}
            authorization-grant-type: authorization_code
            redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
            scope: pages_manage_posts,pages_read_engagement
          linkedin:
            client-id: ${LINKEDIN_CLIENT_ID:}
            client-secret: ${LINKEDIN_CLIENT_SECRET:}
            authorization-grant-type: authorization_code
            redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
            scope: r_liteprofile,w_member_social
        provider:
          instagram:
            authorization-uri: https://api.instagram.com/oauth/authorize
            token-uri: https://api.instagram.com/oauth/access_token
            user-info-uri: https://graph.instagram.com/me
          facebook:
            authorization-uri: https://www.facebook.com/v18.0/dialog/oauth
            token-uri: https://graph.facebook.com/v18.0/oauth/access_token
            user-info-uri: https://graph.facebook.com/me
          linkedin:
            authorization-uri: https://www.linkedin.com/oauth/v2/authorization
            token-uri: https://www.linkedin.com/oauth/v2/accessToken
            user-info-uri: https://api.linkedin.com/v2/people/~

# ============================================
# ACTUATOR & MONITORING
# ============================================
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics
      base-path: /actuator
  endpoint:
    health:
      show-details: always

# ============================================
# LOGGING CONFIGURATION
# ============================================
logging:
  level:
    "[com.social.media]": ${LOG_LEVEL:INFO}
    "[org.springframework.security]": WARN
    "[org.hibernate.SQL]": ${SQL_LOG_LEVEL:WARN}
  file:
    name: ${LOG_FILE_PATH:./logs/social-media-manager.log}

# ============================================
# SPRINGDOC OPENAPI CONFIGURATION
# ============================================
springdoc:
  api-docs:
    path: /v3/api-docs
    enabled: true
  swagger-ui:
    path: /swagger-ui.html
    enabled: true