From 34cd7d6585992c03298c175ab5d22ad059b58cdb Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 10 Jan 2025 10:52:43 -0500 Subject: [PATCH] Use `config_for` for `Mastodon::Version` metadata/prerelease values (#33548) --- config/mastodon.yml | 3 +++ lib/mastodon/version.rb | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config/mastodon.yml b/config/mastodon.yml index 2c09c59e0a..e20ba0ab05 100644 --- a/config/mastodon.yml +++ b/config/mastodon.yml @@ -2,3 +2,6 @@ shared: self_destruct_value: <%= ENV.fetch('SELF_DESTRUCT', nil) %> software_update_url: <%= ENV.fetch('UPDATE_CHECK_URL', 'https://api.joinmastodon.org/update-check') %> + version: + metadata: <%= ENV.fetch('MASTODON_VERSION_METADATA', nil) %> + prerelease: <%= ENV.fetch('MASTODON_VERSION_PRERELEASE', nil) %> diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index f132c3a548..ddde4a993d 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -21,11 +21,11 @@ module Mastodon end def prerelease - ENV['MASTODON_VERSION_PRERELEASE'].presence || default_prerelease + version_configuration[:prerelease].presence || default_prerelease end def build_metadata - ENV.fetch('MASTODON_VERSION_METADATA', nil) + version_configuration[:metadata] end def to_a @@ -77,5 +77,9 @@ module Mastodon def user_agent @user_agent ||= "Mastodon/#{Version} (#{HTTP::Request::USER_AGENT}; +http#{Rails.configuration.x.use_https ? 's' : ''}://#{Rails.configuration.x.web_domain}/)" end + + def version_configuration + Rails.configuration.x.mastodon.version + end end end