mirror of https://github.com/mastodon/mastodon
Split `timeline_preview` setting into more granular settings (#36338)
parent
62f91eddf4
commit
2d2c525097
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Timelines::TopicController < Api::V1::Timelines::BaseController
|
||||
before_action :require_user!, if: :require_auth?
|
||||
|
||||
private
|
||||
|
||||
def require_auth?
|
||||
if truthy_param?(:local)
|
||||
Setting.local_topic_feed_access != 'public'
|
||||
elsif truthy_param?(:remote)
|
||||
Setting.remote_topic_feed_access != 'public'
|
||||
else
|
||||
Setting.local_topic_feed_access != 'public' || Setting.remote_topic_feed_access != 'public'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MigrateTimelinePreviewSetting < ActiveRecord::Migration[8.0]
|
||||
class Setting < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
setting = Setting.find_by(var: 'timeline_preview')
|
||||
return unless setting.present? && setting.attributes['value'].present?
|
||||
|
||||
value = YAML.safe_load(setting.attributes['value'], permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol])
|
||||
|
||||
Setting.upsert_all(
|
||||
%w(local_live_feed_access remote_live_feed_access local_topic_feed_access remote_topic_feed_access).map do |var|
|
||||
{ var: var, value: value ? "--- public\n" : "--- authenticated\n" }
|
||||
end,
|
||||
unique_by: :var
|
||||
)
|
||||
end
|
||||
|
||||
def down; end
|
||||
end
|
||||
Loading…
Reference in New Issue