From 650cfae270b06d5939790f403c71538ab5c7aea5 Mon Sep 17 00:00:00 2001 From: KMY Date: Mon, 24 Jul 2023 12:12:37 +0900 Subject: [PATCH] Add hide_local_users_for_anonymous setting --- app/models/form/admin_settings.rb | 2 ++ app/models/public_feed.rb | 6 +++++- app/models/tag_feed.rb | 2 +- app/views/admin/ng_words/show.html.haml | 3 +++ config/locales/en.yml | 1 + config/locales/ja.yml | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 61071a5b76..2b77353783 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -36,6 +36,7 @@ class Form::AdminSettings captcha_enabled ng_words enable_block_emoji_reaction_settings + hide_local_users_for_anonymous ).freeze INTEGER_KEYS = %i( @@ -57,6 +58,7 @@ class Form::AdminSettings require_invite_text captcha_enabled enable_block_emoji_reaction_settings + hide_local_users_for_anonymous ).freeze UPLOAD_KEYS = %i( diff --git a/app/models/public_feed.rb b/app/models/public_feed.rb index 929f062562..3579623232 100644 --- a/app/models/public_feed.rb +++ b/app/models/public_feed.rb @@ -24,7 +24,7 @@ class PublicFeed scope.merge!(without_replies_scope) unless with_replies? scope.merge!(without_reblogs_scope) unless with_reblogs? scope.merge!(local_only_scope) if local_only? - scope.merge!(remote_only_scope) if remote_only? + scope.merge!(remote_only_scope) if remote_only? || hide_local_users? scope.merge!(global_timeline_only_scope) if global_timeline? scope.merge!(account_filters_scope) if account? scope.merge!(media_only_scope) if media_only? @@ -54,6 +54,10 @@ class PublicFeed options[:remote] end + def hide_local_users? + @account.nil? && Setting.hide_local_users_for_anonymous + end + def global_timeline? !options[:remote] && !options[:local] end diff --git a/app/models/tag_feed.rb b/app/models/tag_feed.rb index fe805ed0dc..14f4afe737 100644 --- a/app/models/tag_feed.rb +++ b/app/models/tag_feed.rb @@ -29,7 +29,7 @@ class TagFeed < PublicFeed scope.merge!(tagged_with_all_scope) scope.merge!(tagged_with_none_scope) scope.merge!(local_only_scope) if local_only? - scope.merge!(remote_only_scope) if remote_only? + scope.merge!(remote_only_scope) if remote_only? || hide_local_users? scope.merge!(account_filters_scope) if account? scope.merge!(media_only_scope) if media_only? scope.merge!(anonymous_scope) unless account? diff --git a/app/views/admin/ng_words/show.html.haml b/app/views/admin/ng_words/show.html.haml index 419a28b54d..e8a87519c6 100644 --- a/app/views/admin/ng_words/show.html.haml +++ b/app/views/admin/ng_words/show.html.haml @@ -13,5 +13,8 @@ .fields-group = f.input :enable_block_emoji_reaction_settings, wrapper: :with_label, as: :boolean, label: t('admin.ng_words.enable_block_emoji_reaction_settings') + .fields-group + = f.input :hide_local_users_for_anonymous, wrapper: :with_label, as: :boolean, label: t('admin.ng_words.hide_local_users_for_anonymous') + .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f280594b8..a70a11bf75 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -597,6 +597,7 @@ en: title: Media attachments ng_words: enable_block_emoji_reaction_settings: Enable block emoji reactions settings for users + hide_local_users_for_anonymous: Hide timeline local user posts from anonymous keywords: Reject keywords title: NG words and against spams relationships: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index bb6b6d263b..49df945803 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -596,6 +596,7 @@ ja: title: 投稿された画像 ng_words: enable_block_emoji_reaction_settings: 各ユーザーにスタンプ機能のブロック設定項目を解放する + hide_local_users_for_anonymous: ログインしていない状態でローカルユーザーの投稿をタイムラインから取得できないようにする keywords: 投稿できないキーワード title: NGワードとスパム relationships: