use Mix.Config

# For staging, we configure the host to read the PORT
# from the system environment. Therefore, you will need
# to set PORT=80 before running your server.
#
# You should also configure the url host to something
# meaningful, we use this information when generating URLs.
#
# Finally, we also include the path to a manifest
# containing the digested version of static files. This
# manifest is generated by the mix phoenix.digest task
# which you typically run after static files are built.
config :code_corps, CodeCorpsWeb.Endpoint,
  http: [port: {:system, "PORT"}],
  instrumenters: [Timber.PhoenixInstrumenter],
  url: [scheme: "http", host: "api.pbqrpbecf.org", port: 80],
  secret_key_base: System.get_env("SECRET_KEY_BASE")

config :code_corps, site_url: "http://www.pbqrpbecf.org"

# Configure your database
config :code_corps, CodeCorps.Repo,
  adapter: Ecto.Adapters.Postgres,
  loggers: [{Timber.Ecto, :log, [:info]}],
  url: System.get_env("DATABASE_URL"),
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  ssl: true

# CORS allowed origins
config :code_corps, allowed_origins: [
  "http://pbqrpbecf.org",
  "http://www.pbqrpbecf.org",
  "https://pbqrpbecf.org",
  "https://www.pbqrpbecf.org"
]

config :code_corps, CodeCorps.Guardian,
  secret_key: System.get_env("GUARDIAN_SECRET_KEY")

# Timber logging
config :logger,
  level: :info,
  backends: [Timber.Logger]
config :timber, :transport, Timber.Transports.IODevice

# Configures Segment for analytics
config :code_corps, :analytics, CodeCorps.Analytics.SegmentAPI

config :sentry,
  environment_name: Mix.env || :staging

# Configures stripe for staging
config :code_corps, :stripe, Stripe
config :code_corps, :stripe_env, :staging

config :code_corps, CodeCorps.Mailer,
  adapter: Bamboo.PostmarkAdapter,
  api_key: System.get_env("POSTMARK_API_KEY")

config :code_corps,
  postmark_forgot_password_template: "1989481",
  postmark_message_initiated_by_project_template: "4324241",
  postmark_organization_invite_email_template: "3442401",
  postmark_project_approval_request_template: "4105823",
  postmark_project_approved_template: "4105744",
  postmark_project_user_acceptance_template: "1447022",
  postmark_project_user_request_template: "4017261",
  postmark_receipt_template: "1252361",
  postmark_reply_to_conversation_template: "4324243"

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
#     config :code_corps, CodeCorpsWeb.Endpoint,
#       ...
#       url: [host: "example.com", port: 443],
#       https: [port: 443,
#               keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
#               certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
#
# Where those two env variables return an absolute path to
# the key and cert in disk or a relative path inside priv,
# for example "priv/ssl/server.key".
#
# We also recommend setting `force_ssl`, ensuring no data is
# ever sent via http, always redirecting to https:
#
#     config :code_corps, CodeCorpsWeb.Endpoint,
#       force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.

# ## Using releases
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start the server for all endpoints:
#
#     config :phoenix, :serve_endpoints, true
#
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
#     config :code_corps, CodeCorpsWeb.Endpoint, server: true
#
# You will also need to set the application root to `.` in order
# for the new static assets to be served after a hot upgrade:
#
#     config :code_corps, CodeCorpsWeb.Endpoint, root: "."
