Skip to content

Commit

Permalink
Remove: #454 リンクプレビューを生成する設定の削除、無効化 (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode authored Jan 15, 2024
1 parent ac65d05 commit aefe147
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 44 deletions.
8 changes: 0 additions & 8 deletions app/models/concerns/account/other_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ def translatable_private?
false
end

def link_preview?
return user.setting_link_preview if local? && user.present?
return settings['link_preview'] if settings.present? && settings.key?('link_preview')

true
end

def allow_quote?
return user.setting_allow_quote if local? && user.present?
return settings['allow_quote'] if settings.present? && settings.key?('allow_quote')
Expand Down Expand Up @@ -95,7 +88,6 @@ def public_settings
'hide_following_count' => hide_following_count?,
'hide_followers_count' => hide_followers_count?,
'translatable_private' => translatable_private?,
'link_preview' => link_preview?,
'allow_quote' => allow_quote?,
'emoji_reaction_policy' => Setting.enable_emoji_reaction ? emoji_reaction_policy.to_s : 'block',
}
Expand Down
4 changes: 0 additions & 4 deletions app/models/concerns/user/has_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ def setting_translatable_private
settings['translatable_private']
end

def setting_link_preview
settings['link_preview']
end

def setting_dtl_force_visibility
settings['dtl_force_visibility']&.to_sym || :unchange
end
Expand Down
1 change: 0 additions & 1 deletion app/models/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class KeyError < Error; end
setting :theme, default: -> { ::Setting.theme }
setting :noindex, default: -> { ::Setting.noindex }
setting :translatable_private, default: false
setting :link_preview, default: true
setting :bio_markdown, default: false
setting :discoverable_local, default: false
setting :hide_statuses_count, default: false
Expand Down
2 changes: 1 addition & 1 deletion app/services/fetch_link_card_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call(status)
@status = status
@original_url = parse_urls

return if @original_url.nil? || @status.with_preview_card? || !@status.account.link_preview?
return if @original_url.nil? || @status.with_preview_card?

@url = @original_url.to_s

Expand Down
3 changes: 0 additions & 3 deletions app/views/settings/privacy_extra/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
.fields-group
= ff.input :translatable_private, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_translatable_private')

.fields-group
= ff.input :link_preview, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_link_preview'), hint: I18n.t('simple_form.hints.defaults.setting_link_preview')

.fields-group
= f.input :subscription_policy,
as: :radio_buttons,
Expand Down
1 change: 0 additions & 1 deletion config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ en:
setting_hide_network: Hide your social graph
setting_hide_recent_emojis: Hide recent emojis
setting_hide_statuses_count: Hide statuses count
setting_link_preview: Generate post link preview card
setting_lock_follow_from_bot: Request approval about bot follow
setting_public_post_to_unlisted: Convert public post to public unlisted if not using Web app
setting_reduce_motion: Reduce motion in animations
Expand Down
2 changes: 0 additions & 2 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ ja:
setting_emoji_reaction_streaming_notify_impl2: 当該サーバーの独自機能に対応したアプリを利用時に、スタンプ機能を利用できます。動作確認していないため(そもそもそのようなアプリ自体を確認できていないため)正しく動かない場合があります
setting_enable_emoji_reaction: この機能を無効にしても、他の人はあなたの投稿にスタンプをつけられます
setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします
setting_link_preview: プレビュー生成を停止することは、センシティブなサイトへのリンクを頻繁に投稿する人にも有効かもしれません
setting_public_post_to_unlisted: 未対応のサードパーティアプリからもローカル公開で投稿できますが、公開投稿はWeb以外できなくなります
setting_reject_unlisted_subscription: Misskeyやそのフォークは、フォローしていないアカウントの「非収載」投稿を **購読・検索** することができます。これはkmyblueの挙動と異なります。そのようなサーバーに、指定した公開範囲の投稿を「フォロワーのみ」として配送します。ただし構造上、完璧な対応は困難でたまに非収載として配信されること、ご理解ください
setting_show_application: 投稿するのに使用したアプリが投稿の詳細ビューに表示されるようになります
Expand Down Expand Up @@ -287,7 +286,6 @@ ja:
setting_hide_network: 繋がりを隠す
setting_hide_recent_emojis: 絵文字ピッカーで最近使用した絵文字を隠す(絵文字デッキのみを表示する)
setting_hide_statuses_count: 投稿数を隠す
setting_link_preview: リンクのプレビューを生成する
setting_lock_follow_from_bot: botからのフォローを承認制にする
setting_show_quote_in_home: ホーム・リスト・アンテナなどで引用を表示する
setting_show_quote_in_public: 公開タイムライン(ローカル・連合)で引用を表示する
Expand Down
16 changes: 9 additions & 7 deletions spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,9 @@
describe '#public_settings_for_local' do
subject { account.public_settings_for_local }

let(:account) { Fabricate(:user, settings: { link_preview: false, allow_quote: true, hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }
let(:account) { Fabricate(:user, settings: { allow_quote: true, hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }

shared_examples 'some settings' do |permitted, emoji_reaction_policy|
it 'link_preview is disallowed' do
expect(subject['link_preview']).to be permitted.include?(:link_preview)
end

it 'allow_quote is allowed' do
expect(subject['allow_quote']).to be permitted.include?(:allow_quote)
end
Expand All @@ -423,16 +419,22 @@

it_behaves_like 'some settings', %i(allow_quote hide_statuses_count), 'followers_only'

context 'when default true setting is set false' do
let(:account) { Fabricate(:user, settings: { allow_quote: false, hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }

it_behaves_like 'some settings', %i(hide_statuses_count), 'followers_only'
end

context 'when remote user' do
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor', settings: { 'link_preview' => false, 'allow_quote' => true, 'hide_statuses_count' => true, 'emoji_reaction_policy' => 'followers_only' }) }
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor', settings: { 'allow_quote' => true, 'hide_statuses_count' => true, 'emoji_reaction_policy' => 'followers_only' }) }

it_behaves_like 'some settings', %i(allow_quote hide_statuses_count), 'followers_only'
end

context 'when remote user by server other_settings is not supported' do
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') }

it_behaves_like 'some settings', %i(link_preview allow_quote), 'allow'
it_behaves_like 'some settings', %i(allow_quote), 'allow'
end
end

Expand Down
17 changes: 0 additions & 17 deletions spec/services/fetch_link_card_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,6 @@
expect(status.preview_card.title).to eq 'Hello world'
end
end

context 'with URL but author is not allow preview card' do
let(:account) { Fabricate(:user, settings: { link_preview: false }).account }
let(:status) { Fabricate(:status, text: 'http://example.com/html', account: account) }

it 'not create preview card' do
expect(status.preview_card).to be_nil
end
end
end

context 'with a remote status' do
Expand All @@ -282,14 +273,6 @@
it 'ignores URLs to hashtags' do
expect(a_request(:get, 'https://quitter.se/tag/wannacry')).to_not have_been_made
end

context 'with URL but author is not allow preview card' do
let(:account) { Fabricate(:account, domain: 'example.com', settings: { link_preview: false }) }

it 'not create link preview' do
expect(status.preview_card).to be_nil
end
end
end

context 'with a remote status of reference' do
Expand Down

0 comments on commit aefe147

Please sign in to comment.