2025-01-07 07:12:14 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class DawarichSettings
|
2025-05-16 12:51:48 -04:00
|
|
|
BASIC_PAID_PLAN_LIMIT = 10_000_000 # 10 million points
|
|
|
|
|
|
2025-01-07 07:12:14 -05:00
|
|
|
class << self
|
|
|
|
|
def reverse_geocoding_enabled?
|
2025-01-08 22:32:29 -05:00
|
|
|
@reverse_geocoding_enabled ||= photon_enabled? || geoapify_enabled? || nominatim_enabled?
|
2025-01-07 07:12:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def photon_enabled?
|
2025-01-07 07:41:09 -05:00
|
|
|
@photon_enabled ||= PHOTON_API_HOST.present?
|
2025-01-07 07:12:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def photon_uses_komoot_io?
|
2025-01-07 07:41:09 -05:00
|
|
|
@photon_uses_komoot_io ||= PHOTON_API_HOST == 'photon.komoot.io'
|
2025-01-07 07:12:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def geoapify_enabled?
|
2025-01-07 07:41:09 -05:00
|
|
|
@geoapify_enabled ||= GEOAPIFY_API_KEY.present?
|
2025-01-07 07:12:14 -05:00
|
|
|
end
|
2025-01-15 15:52:59 -05:00
|
|
|
|
|
|
|
|
def self_hosted?
|
|
|
|
|
@self_hosted ||= SELF_HOSTED
|
|
|
|
|
end
|
2025-02-15 05:14:50 -05:00
|
|
|
|
2025-02-11 14:45:36 -05:00
|
|
|
def prometheus_exporter_enabled?
|
|
|
|
|
@prometheus_exporter_enabled ||=
|
|
|
|
|
ENV['PROMETHEUS_EXPORTER_ENABLED'].to_s == 'true' &&
|
|
|
|
|
ENV['PROMETHEUS_EXPORTER_HOST'].present? &&
|
|
|
|
|
ENV['PROMETHEUS_EXPORTER_PORT'].present?
|
2025-01-24 06:01:54 -05:00
|
|
|
end
|
|
|
|
|
|
2025-02-11 15:13:59 -05:00
|
|
|
def nominatim_enabled?
|
|
|
|
|
@nominatim_enabled ||= NOMINATIM_API_HOST.present?
|
2025-01-24 06:01:54 -05:00
|
|
|
end
|
2025-05-12 16:33:47 -04:00
|
|
|
|
|
|
|
|
def store_geodata?
|
|
|
|
|
@store_geodata ||= STORE_GEODATA
|
|
|
|
|
end
|
2025-09-03 17:57:38 -04:00
|
|
|
|
2025-09-28 07:10:07 -04:00
|
|
|
def family_feature_enabled?
|
|
|
|
|
@family_feature_enabled ||= self_hosted? || family_subscription_active?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def family_subscription_active?
|
|
|
|
|
# Will be implemented when cloud subscriptions are added
|
|
|
|
|
# For now, return false for cloud instances to keep family feature
|
|
|
|
|
# available only for self-hosted instances
|
|
|
|
|
false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def family_feature_available_for?(user)
|
|
|
|
|
return true if self_hosted?
|
|
|
|
|
return false unless user
|
|
|
|
|
|
|
|
|
|
# For cloud instances, check if user has family subscription
|
|
|
|
|
# This will be implemented when subscription system is added
|
|
|
|
|
false
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-03 17:57:38 -04:00
|
|
|
def features
|
|
|
|
|
@features ||= {
|
2025-09-28 07:10:07 -04:00
|
|
|
reverse_geocoding: reverse_geocoding_enabled?,
|
|
|
|
|
family: family_feature_enabled?
|
2025-09-03 17:57:38 -04:00
|
|
|
}
|
|
|
|
|
end
|
2025-01-07 07:12:14 -05:00
|
|
|
end
|
|
|
|
|
end
|