From 7696216cbd35b1ce09bf6f0da4ab4840fd83a148 Mon Sep 17 00:00:00 2001 From: KMY Date: Wed, 20 Sep 2023 18:42:08 +0900 Subject: [PATCH] Change update check source to kmyblue origin --- app/models/form/admin_settings.rb | 2 ++ app/services/software_update_check_service.rb | 11 +++++++++-- app/views/admin/settings/discovery/show.html.haml | 3 +++ config/locales/simple_form.en.yml | 1 + config/locales/simple_form.ja.yml | 1 + config/settings.yml | 1 + spec/services/software_update_check_service_spec.rb | 4 ++-- 7 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 57cd9ca415..08b546561d 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -46,6 +46,7 @@ class Form::AdminSettings receive_other_servers_emoji_reaction streaming_other_servers_emoji_reaction enable_emoji_reaction + check_lts_version_only ).freeze INTEGER_KEYS = %i( @@ -72,6 +73,7 @@ class Form::AdminSettings receive_other_servers_emoji_reaction streaming_other_servers_emoji_reaction enable_emoji_reaction + check_lts_version_only ).freeze UPLOAD_KEYS = %i( diff --git a/app/services/software_update_check_service.rb b/app/services/software_update_check_service.rb index 49b92f104d..0af943a333 100644 --- a/app/services/software_update_check_service.rb +++ b/app/services/software_update_check_service.rb @@ -27,11 +27,18 @@ class SoftwareUpdateCheckService < BaseService end def api_url - ENV.fetch('UPDATE_CHECK_URL', 'https://api.joinmastodon.org/update-check') + ENV.fetch('UPDATE_CHECK_URL', 'https://kmy.blue/update-check') end def version - @version ||= Mastodon::Version.to_s.split('+')[0] + return @version if @version.present? + + if ENV.fetch('UPDATE_CHECK_SOURCE', 'kmyblue') == 'kmyblue' + @version = "#{Mastodon::Version.kmyblue_major}.#{Mastodon::Version.kmyblue_minor}" + @version += '-lts' if Setting.check_lts_version_only + else + @version = Mastodon::Version.to_s.split('+')[0] + end end def process_update_notices!(update_notices) diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml index 60443e6877..6ea9e4fb4b 100644 --- a/app/views/admin/settings/discovery/show.html.haml +++ b/app/views/admin/settings/discovery/show.html.haml @@ -55,6 +55,9 @@ .fields-group = f.input :authorized_fetch, as: :boolean, wrapper: :with_label, label: t('admin.settings.security.authorized_fetch'), warning_hint: authorized_fetch_overridden? ? t('admin.settings.security.authorized_fetch_overridden_hint') : nil, hint: t('admin.settings.security.authorized_fetch_hint'), disabled: authorized_fetch_overridden?, recommended: authorized_fetch_overridden? ? :overridden : nil + .fields-group + = f.input :check_lts_version_only, as: :boolean, wrapper: :with_label, kmyblue: true, hint: false + %h4= t('admin.settings.discovery.follow_recommendations') .fields-group diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 738e5f39c2..56cce1c24d 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -315,6 +315,7 @@ en: activity_api_enabled: Publish aggregate statistics about user activity in the API backups_retention_period: User archive retention period bootstrap_timeline_accounts: Always recommend these accounts to new users + check_lts_version_only: Check kmyblue LTS version only when update check closed_registrations_message: Custom message when sign-ups are not available content_cache_retention_period: Content cache retention period custom_css: Custom CSS diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index 5c72720a33..b5898f5185 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -330,6 +330,7 @@ ja: activity_api_enabled: APIでユーザーアクティビティに関する集計統計を公開する backups_retention_period: ユーザーアーカイブの保持期間 bootstrap_timeline_accounts: おすすめユーザーに常に表示するアカウント + check_lts_version_only: 更新チェックの時、LTSバージョンのみ確認する closed_registrations_message: アカウント作成を停止している時のカスタムメッセージ content_cache_retention_period: コンテンツキャッシュの保持期間 custom_css: カスタムCSS diff --git a/config/settings.yml b/config/settings.yml index 0042b5822e..69b3ed1ee3 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -41,6 +41,7 @@ defaults: &defaults receive_other_servers_emoji_reaction: false streaming_other_servers_emoji_reaction: false enable_emoji_reaction: true + check_lts_version_only: true development: <<: *defaults diff --git a/spec/services/software_update_check_service_spec.rb b/spec/services/software_update_check_service_spec.rb index c8821348ac..7cc99bb09c 100644 --- a/spec/services/software_update_check_service_spec.rb +++ b/spec/services/software_update_check_service_spec.rb @@ -6,7 +6,7 @@ RSpec.describe SoftwareUpdateCheckService, type: :service do subject { described_class.new } shared_examples 'when the feature is enabled' do - let(:full_update_check_url) { "#{update_check_url}?version=#{Mastodon::Version.to_s.split('+')[0]}" } + let(:full_update_check_url) { "#{update_check_url}?version=#{Mastodon::Version.kmyblue_major}.#{Mastodon::Version.kmyblue_minor}-lts" } let(:devops_role) { Fabricate(:user_role, name: 'DevOps', permissions: UserRole::FLAGS[:view_devops]) } let(:owner_user) { Fabricate(:user, role: UserRole.find_by(name: 'Owner')) } @@ -139,7 +139,7 @@ RSpec.describe SoftwareUpdateCheckService, type: :service do end context 'when using the default update checking API' do - let(:update_check_url) { 'https://api.joinmastodon.org/update-check' } + let(:update_check_url) { 'https://kmy.blue/update-check' } it_behaves_like 'when the feature is enabled' end