1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
This commit is contained in:
Matt Jankowski 2024-07-31 14:07:10 +00:00 committed by GitHub
commit 811b06c9a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 12 deletions

View file

@ -24,7 +24,7 @@ class SoftwareUpdate < ApplicationRecord
class << self
def check_enabled?
ENV['UPDATE_CHECK_URL'] != ''
Rails.configuration.x.mastodon.software_update_url.present?
end
def pending_to_a

View file

@ -27,7 +27,7 @@ class SoftwareUpdateCheckService < BaseService
end
def api_url
ENV.fetch('UPDATE_CHECK_URL', 'https://api.joinmastodon.org/update-check')
Rails.configuration.x.mastodon.software_update_url
end
def version

View file

@ -112,6 +112,9 @@ module Mastodon
end
end
# Load defaults from config/mastodon.yml
config.x.mastodon = config_for(:mastodon)
config.to_prepare do
Doorkeeper::AuthorizationsController.layout 'modal'
Doorkeeper::AuthorizedApplicationsController.layout 'admin'

3
config/mastodon.yml Normal file
View file

@ -0,0 +1,3 @@
---
shared:
software_update_url: <%= ENV.fetch('UPDATE_CHECK_URL', 'https://api.joinmastodon.org/update-check') %>

View file

@ -6,7 +6,11 @@ SimpleNavigation::Configuration.run do |navigation|
navigation.items do |n|
n.item :web, safe_join([fa_icon('chevron-left fw'), t('settings.back')]), root_path
n.item :software_updates, safe_join([fa_icon('exclamation-circle fw'), t('admin.critical_update_pending')]), admin_software_updates_path, if: -> { ENV['UPDATE_CHECK_URL'] != '' && current_user.can?(:view_devops) && SoftwareUpdate.urgent_pending? }, html: { class: 'warning' }
n.item :software_updates,
safe_join([fa_icon('exclamation-circle fw'), t('admin.critical_update_pending')]),
admin_software_updates_path,
if: -> { Rails.configuration.x.mastodon.software_update_url.present? && current_user.can?(:view_devops) && SoftwareUpdate.urgent_pending? },
html: { class: 'warning' }
n.item :profile, safe_join([fa_icon('user fw'), t('settings.profile')]), settings_profile_path, if: -> { current_user.functional? && !self_destruct }, highlights_on: %r{/settings/profile|/settings/featured_tags|/settings/verification|/settings/privacy}

View file

@ -27,9 +27,10 @@ describe Admin::SystemCheck::SoftwareVersionCheck do
context 'when checks are disabled' do
around do |example|
ClimateControl.modify UPDATE_CHECK_URL: '' do
example.run
end
original = Rails.configuration.x.mastodon.software_update_url
Rails.configuration.x.mastodon.software_update_url = ''
example.run
Rails.configuration.x.mastodon.software_update_url = original
end
it 'returns true' do

View file

@ -124,9 +124,10 @@ RSpec.describe SoftwareUpdateCheckService do
context 'when update checking is disabled' do
around do |example|
ClimateControl.modify UPDATE_CHECK_URL: '' do
example.run
end
original = Rails.configuration.x.mastodon.software_update_url
Rails.configuration.x.mastodon.software_update_url = ''
example.run
Rails.configuration.x.mastodon.software_update_url = original
end
before do
@ -148,9 +149,10 @@ RSpec.describe SoftwareUpdateCheckService do
let(:update_check_url) { 'https://api.example.com/update_check' }
around do |example|
ClimateControl.modify UPDATE_CHECK_URL: 'https://api.example.com/update_check' do
example.run
end
original = Rails.configuration.x.mastodon.software_update_url
Rails.configuration.x.mastodon.software_update_url = 'https://api.example.com/update_check'
example.run
Rails.configuration.x.mastodon.software_update_url = original
end
it_behaves_like 'when the feature is enabled'