2024-04-13 09:28:45 -04:00
|
|
|
# Dynamic settings the user can change within the app (helpful for self-hosting)
|
|
|
|
class Setting < RailsSettings::Base
|
|
|
|
cache_prefix { "v1" }
|
|
|
|
|
|
|
|
field :render_deploy_hook,
|
|
|
|
type: :string,
|
|
|
|
default: ENV["RENDER_DEPLOY_HOOK"],
|
|
|
|
validates: { allow_blank: true, format: { with: /\Ahttps:\/\/api\.render\.com\/deploy\/srv-.+\z/ } }
|
|
|
|
|
|
|
|
field :upgrades_mode,
|
|
|
|
type: :string,
|
|
|
|
default: ENV.fetch("UPGRADES_MODE", "manual"),
|
|
|
|
validates: { inclusion: { in: %w[manual auto] } }
|
|
|
|
|
|
|
|
field :upgrades_target,
|
|
|
|
type: :string,
|
|
|
|
default: ENV.fetch("UPGRADES_TARGET", "release"),
|
|
|
|
validates: { inclusion: { in: %w[release commit] } }
|
2024-04-29 22:44:24 +02:00
|
|
|
|
|
|
|
field :app_domain, type: :string, default: ENV["APP_DOMAIN"]
|
|
|
|
field :email_sender, type: :string, default: ENV["EMAIL_SENDER"]
|
|
|
|
|
|
|
|
scope :smtp_settings do
|
|
|
|
field :smtp_host, type: :string, read_only: true, default: ENV["SMTP_ADDRESS"]
|
|
|
|
field :smtp_port, type: :string, read_only: true, default: ENV["SMTP_PORT"]
|
|
|
|
field :smtp_username, type: :string, read_only: true, default: ENV["SMTP_USERNAME"]
|
|
|
|
field :smtp_password, type: :string, read_only: true, default: ENV["SMTP_PASSWORD"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.smtp_settings_populated?
|
|
|
|
Setting.defined_fields.select { |f| f.scope == :smtp_settings }.map(&:read).all?(&:present?)
|
|
|
|
end
|
2024-04-13 09:28:45 -04:00
|
|
|
end
|