mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-06 00:52:42 +00:00
Split timeline_preview
boolean setting in 4 settings
This commit is contained in:
parent
4809b38f6e
commit
975e23f96d
|
@ -3,14 +3,8 @@
|
||||||
class Api::V1::Timelines::BaseController < Api::BaseController
|
class Api::V1::Timelines::BaseController < Api::BaseController
|
||||||
after_action :insert_pagination_headers, unless: -> { @statuses.empty? }
|
after_action :insert_pagination_headers, unless: -> { @statuses.empty? }
|
||||||
|
|
||||||
before_action :require_user!, if: :require_auth?
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def require_auth?
|
|
||||||
!Setting.timeline_preview
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_collection
|
def pagination_collection
|
||||||
@statuses
|
@statuses
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
class Api::V1::Timelines::HomeController < Api::V1::Timelines::BaseController
|
class Api::V1::Timelines::HomeController < Api::V1::Timelines::BaseController
|
||||||
include AsyncRefreshesConcern
|
include AsyncRefreshesConcern
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:statuses' }, only: [:show]
|
before_action -> { doorkeeper_authorize! :read, :'read:statuses' }
|
||||||
before_action :require_user!, only: [:show]
|
before_action :require_user!
|
||||||
|
|
||||||
PERMITTED_PARAMS = %i(local limit).freeze
|
PERMITTED_PARAMS = %i(local limit).freeze
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::Timelines::LinkController < Api::V1::Timelines::BaseController
|
class Api::V1::Timelines::LinkController < Api::V1::Timelines::TopicController
|
||||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
||||||
before_action :set_preview_card
|
before_action :set_preview_card
|
||||||
before_action :set_statuses
|
before_action :set_statuses
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class Api::V1::Timelines::PublicController < Api::V1::Timelines::BaseController
|
class Api::V1::Timelines::PublicController < Api::V1::Timelines::BaseController
|
||||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
||||||
|
before_action :require_user!, if: :require_auth?
|
||||||
|
|
||||||
PERMITTED_PARAMS = %i(local remote limit only_media).freeze
|
PERMITTED_PARAMS = %i(local remote limit only_media).freeze
|
||||||
|
|
||||||
|
@ -13,6 +14,16 @@ class Api::V1::Timelines::PublicController < Api::V1::Timelines::BaseController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def require_auth?
|
||||||
|
if truthy_param?(:local)
|
||||||
|
Setting.local_live_feed_access != 'public'
|
||||||
|
elsif truthy_param?(:remote)
|
||||||
|
Setting.remote_live_feed_access != 'public'
|
||||||
|
else
|
||||||
|
Setting.local_live_feed_access != 'public' || Setting.remote_live_feed_access != 'public'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
preloaded_public_statuses_page
|
preloaded_public_statuses_page
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::Timelines::TagController < Api::V1::Timelines::BaseController
|
class Api::V1::Timelines::TagController < Api::V1::Timelines::TopicController
|
||||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
||||||
before_action :load_tag
|
before_action :load_tag
|
||||||
|
|
||||||
|
@ -14,10 +14,6 @@ class Api::V1::Timelines::TagController < Api::V1::Timelines::BaseController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def require_auth?
|
|
||||||
!Setting.timeline_preview
|
|
||||||
end
|
|
||||||
|
|
||||||
def load_tag
|
def load_tag
|
||||||
@tag = Tag.find_normalized(params[:id])
|
@tag = Tag.find_normalized(params[:id])
|
||||||
end
|
end
|
||||||
|
|
17
app/controllers/api/v1/timelines/topic_controller.rb
Normal file
17
app/controllers/api/v1/timelines/topic_controller.rb
Normal file
|
@ -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
|
|
@ -12,7 +12,10 @@ defaults: &defaults
|
||||||
registrations_mode: 'none'
|
registrations_mode: 'none'
|
||||||
profile_directory: true
|
profile_directory: true
|
||||||
closed_registrations_message: ''
|
closed_registrations_message: ''
|
||||||
timeline_preview: true
|
local_live_feed_access: 'public'
|
||||||
|
remote_live_feed_access: 'public'
|
||||||
|
local_topic_feed_access: 'public'
|
||||||
|
remote_topic_feed_access: 'public'
|
||||||
show_staff_badge: true
|
show_staff_badge: true
|
||||||
preview_sensitive_media: false
|
preview_sensitive_media: false
|
||||||
noindex: false
|
noindex: false
|
||||||
|
|
|
@ -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
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_09_24_170259) do
|
ActiveRecord::Schema[8.0].define(version: 2025_10_02_140103) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_catalog.plpgsql"
|
enable_extension "pg_catalog.plpgsql"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user