Rename feed access setting values for consistency with domain block audiences

This commit is contained in:
Claire 2025-10-23 14:13:50 +02:00
parent 2fa5dd6d1f
commit 39d2f56beb
10 changed files with 46 additions and 23 deletions

View File

@ -16,11 +16,11 @@ class Api::V1::Timelines::PublicController < Api::V1::Timelines::BaseController
def require_auth? def require_auth?
if truthy_param?(:local) if truthy_param?(:local)
Setting.local_live_feed_access != 'public' Setting.local_live_feed_access != 'all'
elsif truthy_param?(:remote) elsif truthy_param?(:remote)
Setting.remote_live_feed_access != 'public' Setting.remote_live_feed_access != 'all'
else else
Setting.local_live_feed_access != 'public' || Setting.remote_live_feed_access != 'public' Setting.local_live_feed_access != 'all' || Setting.remote_live_feed_access != 'all'
end end
end end

View File

@ -7,11 +7,11 @@ class Api::V1::Timelines::TopicController < Api::V1::Timelines::BaseController
def require_auth? def require_auth?
if truthy_param?(:local) if truthy_param?(:local)
Setting.local_topic_feed_access != 'public' Setting.local_topic_feed_access != 'all'
elsif truthy_param?(:remote) elsif truthy_param?(:remote)
Setting.remote_topic_feed_access != 'public' Setting.remote_topic_feed_access != 'all'
else else
Setting.local_topic_feed_access != 'public' || Setting.remote_topic_feed_access != 'public' Setting.local_topic_feed_access != 'all' || Setting.remote_topic_feed_access != 'all'
end end
end end
end end

View File

@ -33,10 +33,10 @@ interface InitialStateMeta {
single_user_mode: boolean; single_user_mode: boolean;
source_url: string; source_url: string;
streaming_api_base_url: string; streaming_api_base_url: string;
local_live_feed_access: 'public' | 'authenticated' | 'disabled'; local_live_feed_access: 'all' | 'users' | 'disabled';
remote_live_feed_access: 'public' | 'authenticated' | 'disabled'; remote_live_feed_access: 'all' | 'users' | 'disabled';
local_topic_feed_access: 'public' | 'authenticated' | 'disabled'; local_topic_feed_access: 'all' | 'users' | 'disabled';
remote_topic_feed_access: 'public' | 'authenticated' | 'disabled'; remote_topic_feed_access: 'all' | 'users' | 'disabled';
title: string; title: string;
show_trends: boolean; show_trends: boolean;
trends_as_landing_page: boolean; trends_as_landing_page: boolean;

View File

@ -27,12 +27,12 @@ export function canManageReports(permissions: number) {
export const canViewFeed = ( export const canViewFeed = (
signedIn: boolean, signedIn: boolean,
permissions: number, permissions: number,
setting: 'public' | 'authenticated' | 'disabled' | undefined, setting: 'all' | 'users' | 'disabled' | undefined,
) => { ) => {
switch (setting) { switch (setting) {
case 'public': case 'all':
return true; return true;
case 'authenticated': case 'users':
return signedIn; return signedIn;
case 'disabled': case 'disabled':
default: default:

View File

@ -87,7 +87,7 @@ class Form::AdminSettings
DESCRIPTION_LIMIT = 200 DESCRIPTION_LIMIT = 200
DOMAIN_BLOCK_AUDIENCES = %w(disabled users all).freeze DOMAIN_BLOCK_AUDIENCES = %w(disabled users all).freeze
REGISTRATION_MODES = %w(open approved none).freeze REGISTRATION_MODES = %w(open approved none).freeze
FEED_ACCESS_MODES = %w(public authenticated disabled).freeze FEED_ACCESS_MODES = %w(all users disabled).freeze
attr_accessor(*KEYS) attr_accessor(*KEYS)

View File

@ -44,9 +44,9 @@ class PublicFeed
def user_has_access_to_feed?(setting) def user_has_access_to_feed?(setting)
case setting case setting
when 'public' when 'public', 'all'
true true
when 'authenticated' when 'authenticated', 'users'
@account&.user&.functional? @account&.user&.functional?
when 'disabled' when 'disabled'
@account&.user&.can?(:view_feeds) @account&.user&.can?(:view_feeds)

View File

@ -852,9 +852,9 @@ en:
users: To logged-in local users users: To logged-in local users
feed_access: feed_access:
modes: modes:
authenticated: Authenticated users only all: Everyone
disabled: Require specific user role disabled: Require specific user role
public: Everyone users: Authenticated users only
registrations: registrations:
moderation_recommandation: Please make sure you have an adequate and reactive moderation team before you open registrations to everyone! moderation_recommandation: Please make sure you have an adequate and reactive moderation team before you open registrations to everyone!
preamble: Control who can create an account on your server. preamble: Control who can create an account on your server.

View File

@ -12,10 +12,10 @@ defaults: &defaults
registrations_mode: 'none' registrations_mode: 'none'
profile_directory: true profile_directory: true
closed_registrations_message: '' closed_registrations_message: ''
local_live_feed_access: 'public' local_live_feed_access: 'all'
remote_live_feed_access: 'public' remote_live_feed_access: 'all'
local_topic_feed_access: 'public' local_topic_feed_access: 'all'
remote_topic_feed_access: 'public' remote_topic_feed_access: 'all'
show_staff_badge: true show_staff_badge: true
preview_sensitive_media: false preview_sensitive_media: false
noindex: false noindex: false

View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
class MigrateFeedAccessValues < ActiveRecord::Migration[8.0]
class Setting < ApplicationRecord; end
def up
%w(local_live_feed_access remote_live_feed_access local_topic_feed_access remote_topic_feed_access).each do |var|
setting = Setting.find_by(var: var)
next unless setting.present? && setting.attributes['value'].present?
value = YAML.safe_load(setting.attributes['value'], permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol])
case value
when 'public'
setting.update(value: "--- all\n")
when 'authenticated'
setting.update(value: "--- users\n")
end
end
end
def down; end
end

View File

@ -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_10_07_142305) do ActiveRecord::Schema[8.0].define(version: 2025_10_23_125005) 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"