Add confirmation for follow from the bot

This commit is contained in:
noellabo 2022-07-05 05:09:24 +09:00
parent 40d4f82690
commit 439f9c18b2
11 changed files with 30 additions and 4 deletions

View file

@ -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)
)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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!

View file

@ -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

View file

@ -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

View file

@ -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に切り抜く

View file

@ -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

View file

@ -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