diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 76e20ad99..78f447799 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -91,6 +91,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_info_font_size, :setting_content_emoji_reaction_size, :setting_hide_bot_on_public_timeline, + :setting_confirm_follow_from_bot, notification_emails: %i(follow follow_request reblog favourite emoji_reaction status_reference mention digest report pending_account trending_tag), interactions: %i(must_be_follower must_be_following must_be_following_dm) ) diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index 4efb84b8c..c2e54319d 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -30,7 +30,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity follow_request = FollowRequest.create!(account: @account, target_account: target_account, uri: @json['id']) - if target_account.locked? || @account.silenced? + if target_account.locked? || @account.silenced? || @account.bot? && target_account.user.setting_confirm_follow_from_bot NotifyService.new.call(target_account, :follow_request, follow_request) else AuthorizeFollowService.new.call(@account, target_account) diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index a5a8a4378..4ebe5f6c3 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -85,6 +85,7 @@ class UserSettingsDecorator user.settings['info_font_size'] = info_font_size_preference if change?('setting_info_font_size') user.settings['content_emoji_reaction_size'] = content_emoji_reaction_size_preference if change?('setting_content_emoji_reaction_size') user.settings['hide_bot_on_public_timeline'] = hide_bot_on_public_timeline_preference if change?('setting_hide_bot_on_public_timeline') + user.settings['confirm_follow_from_bot'] = confirm_follow_from_bot_preference if change?('setting_confirm_follow_from_bot') end def merged_notification_emails @@ -311,6 +312,10 @@ end boolean_cast_setting 'setting_hide_bot_on_public_timeline' end + def confirm_follow_from_bot_preference + boolean_cast_setting 'setting_confirm_follow_from_bot' + end + def boolean_cast_setting(key) ActiveModel::Type::Boolean.new.cast(settings[key]) end diff --git a/app/models/user.rb b/app/models/user.rb index 0a1b1ecbe..393e77921 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -140,7 +140,7 @@ class User < ApplicationRecord :content_font_size, :info_font_size, :content_emoji_reaction_size, :multi_column_customize, :multi_column_content_font_size, :multi_column_info_font_size, :multi_column_content_emoji_reaction_size, :mobile_customize, :mobile_content_font_size, :mobile_info_font_size, :mobile_content_emoji_reaction_size, - :hide_bot_on_public_timeline, + :hide_bot_on_public_timeline, :confirm_follow_from_bot, to: :settings, prefix: :setting, allow_nil: false diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index b7d6593f9..fc32699d3 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -69,6 +69,7 @@ class InitialStateSerializer < ActiveModel::Serializer store[:info_font_size] = object.current_account.user.setting_info_font_size store[:content_emoji_reaction_size] = object.current_account.user.setting_content_emoji_reaction_size store[:hide_bot_on_public_timeline] = object.current_account.user.setting_hide_bot_on_public_timeline + store[:confirm_follow_from_bot] = object.current_account.user.setting_confirm_follow_from_bot else store[:auto_play_gif] = Setting.auto_play_gif store[:display_media] = Setting.display_media diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index d8e3f4109..6961db276 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -37,7 +37,7 @@ class FollowService < BaseService # and the feeds are being merged mark_home_feed_as_partial! if @source_account.not_following_anyone? - if (@target_account.locked? && !@options[:bypass_locked]) || @source_account.silenced? || @target_account.activitypub? + if ((@target_account.locked? || @target_account.local? && @source_account.bot? && @target_account.user.setting_confirm_follow_from_bot) && !@options[:bypass_locked]) || @source_account.silenced? || @target_account.activitypub? request_follow! elsif @target_account.local? direct_follow! diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index da8559703..70993810f 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -91,6 +91,9 @@ .fields-group = f.input :setting_match_visibility_of_references, as: :boolean, wrapper: :with_label, fedibird_features: true + .fields-group + = f.input :setting_confirm_follow_from_bot, as: :boolean, wrapper: :with_label, fedibird_features: true + -# .fields-group -# = f.input :setting_show_target, as: :boolean, wrapper: :with_label diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 7b60cc595..5e19f9609 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -55,6 +55,7 @@ en: scopes: Which APIs the application will be allowed to access. If you select a top-level scope, you don't need to select individual ones. setting_aggregate_reblogs: Do not show new boosts for posts that have been recently boosted (only affects newly-received boosts) setting_compact_reaction: Emoji reaction display to be only the number of cases, except for the detail display + setting_confirm_follow_from_bot: Manually approve followers from bot accounts setting_default_sensitive: Sensitive media is hidden by default and can be revealed with a click setting_disable_joke_appearance: Disable April Fools' Day and other joke functions setting_display_media_default: Hide media marked as sensitive @@ -209,6 +210,7 @@ en: setting_auto_play_gif: Auto-play animated GIFs setting_boost_modal: Show confirmation dialog before boosting setting_compact_reaction: Compact display of reaction + setting_confirm_follow_from_bot: Require follow requests from bot setting_content_emoji_reaction_size: Emoji reaction size setting_content_font_size: Content font size setting_crop_images: Crop images in non-expanded posts to 16x9 diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index e80d2476d..91b3548e1 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -55,6 +55,7 @@ ja: scopes: アプリの API に許可するアクセス権を選択してください。最上位のスコープを選択する場合、個々のスコープを選択する必要はありません。 setting_aggregate_reblogs: 最近ブーストされた投稿が新たにブーストされても表示しません (設定後受信したものにのみ影響) setting_compact_reaction: 詳細表示以外の絵文字リアクション表示を件数のみにする + setting_confirm_follow_from_bot: Botアカウントからのフォローを手動で承認する setting_default_sensitive: 閲覧注意状態のメディアはデフォルトでは内容が伏せられ、クリックして初めて閲覧できるようになります setting_disable_joke_appearance: エイプリルフール等のジョーク機能を無効にします setting_display_media_default: 閲覧注意としてマークされたメディアは隠す @@ -209,6 +210,7 @@ ja: setting_auto_play_gif: アニメーションGIFを自動再生する setting_boost_modal: ブーストする前に確認ダイアログを表示する setting_compact_reaction: リアクションをコンパクトに表示 + setting_confirm_follow_from_bot: Bot承認制アカウントにする setting_content_emoji_reaction_size: 投稿の絵文字リアクションのサイズ setting_content_font_size: 投稿のフォントサイズ setting_crop_images: 投稿の詳細以外では画像を16:9に切り抜く diff --git a/config/settings.yml b/config/settings.yml index cf9b2aec2..2af305313 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -103,7 +103,8 @@ defaults: &defaults unselect_reference_modal: false hexagon_avatar: false enable_empty_column: false - hide_bot_on_public_timeline: false + hide_bot_on_public_timeline: false + confirm_follow_from_bot: true development: <<: *defaults diff --git a/db/migrate/20220704075207_conservative_setting_to_confirm_follow_from_bot.rb b/db/migrate/20220704075207_conservative_setting_to_confirm_follow_from_bot.rb new file mode 100644 index 000000000..d8d8fe496 --- /dev/null +++ b/db/migrate/20220704075207_conservative_setting_to_confirm_follow_from_bot.rb @@ -0,0 +1,11 @@ +class ConservativeSettingToConfirmFollowFromBot < ActiveRecord::Migration[6.1] + def up + User.joins('join settings on users.id = settings.thing_id').where(settings: {thing_type: :User, var: :new_features_policy, value: "--- conservative\n"}).find_each do |user| + user.settings['confirm_follow_from_bot'] = false + end + end + + def down + # nothing to do + end +end