Split setting for timeline_preview into timeline_preview_local and timeline_preview_remote

This commit is contained in:
Emelia Smith 2024-08-17 18:46:50 +02:00
parent 2d589a5ed4
commit 17ea727950
No known key found for this signature in database
3 changed files with 31 additions and 3 deletions

View file

@ -14,7 +14,8 @@ class Form::AdminSettings
site_terms
registrations_mode
closed_registrations_message
timeline_preview
timeline_preview_local
timeline_preview_remote
bootstrap_timeline_accounts
theme
activity_api_enabled
@ -48,7 +49,8 @@ class Form::AdminSettings
).freeze
BOOLEAN_KEYS = %i(
timeline_preview
timeline_preview_local
timeline_preview_remote
activity_api_enabled
peers_api_enabled
preview_sensitive_media

View file

@ -12,7 +12,8 @@ defaults: &defaults
registrations_mode: 'none'
profile_directory: true
closed_registrations_message: ''
timeline_preview: true
timeline_preview_local: true
timeline_preview_remote: false
show_staff_badge: true
preview_sensitive_media: false
noindex: false

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
class SplitPublicTimelinesSetting < ActiveRecord::Migration[7.1]
def up
previous_setting = Setting.find_by(var: 'timeline_preview')
unless previous_setting.nil?
Setting['timeline_preview_local'] = previous_setting.value
Setting['timeline_preview_remote'] = previous_setting.value
previous_setting.delete
end
end
def down
preview_local = Setting['timeline_preview_local']
preview_remote = Setting['timeline_preview_remote']
unless preview_local.nil? && preview_remote.nil?
preview_timelines = (!preview_local.nil? && preview_local) && (!preview_remote.nil? && preview_remote)
Setting['timeline_preview'] = preview_timelines
end
Setting.where(var: ['timeline_preview_local', 'timeline_preview_remote']).delete_all
end
end