diff --git a/app/models/concerns/account/other_settings.rb b/app/models/concerns/account/other_settings.rb index b81a7ffd79..72f52ba979 100644 --- a/app/models/concerns/account/other_settings.rb +++ b/app/models/concerns/account/other_settings.rb @@ -61,6 +61,7 @@ module Account::OtherSettings def show_emoji_reaction?(account) return false unless Setting.enable_emoji_reaction + return true if local? && account&.local? && user.setting_slip_local_emoji_reaction case emoji_reaction_policy when :block @@ -104,7 +105,9 @@ module Account::OtherSettings end def public_settings_for_local - public_settings.merge(public_master_settings) + s = public_settings + s = s.merge({ 'emoji_reaction_policy' => 'allow' }) if local? && user&.setting_slip_local_emoji_reaction + s.merge(public_master_settings) end end end diff --git a/app/models/concerns/user/has_settings.rb b/app/models/concerns/user/has_settings.rb index de451b3f6c..fae89fca1b 100644 --- a/app/models/concerns/user/has_settings.rb +++ b/app/models/concerns/user/has_settings.rb @@ -91,6 +91,10 @@ module User::HasSettings settings['emoji_reaction_policy'] end + def setting_slip_local_emoji_reaction + settings['slip_local_emoji_reaction'] + end + def setting_unfollow_modal settings['web.unfollow_modal'] end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index 99a0394da8..37540aecd3 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -37,6 +37,7 @@ class UserSettings setting :stop_emoji_reaction_streaming, default: false setting :emoji_reaction_streaming_notify_impl2, default: false setting :emoji_reaction_policy, default: :allow, in: %w(allow outside_only followers_only following_only mutuals_only block) + setting :slip_local_emoji_reaction, default: false setting :unsafe_limited_distribution, default: false setting :dtl_force_visibility, default: :unchange, in: %w(unchange public public_unlisted unlisted) setting :dtl_force_searchability, default: :unchange, in: %w(unchange public public_unlisted) diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index 2d036fe787..9f81957d0d 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -30,6 +30,9 @@ .fields-group.fields-row__column.fields-row__column-12 = ff.input :emoji_reaction_policy, kmyblue: true, collection: %w(allow outside_only followers_only following_only mutuals_only block), label_method: ->(item) { safe_join([t("simple_form.labels.defaults.setting_emoji_reaction_policy_items.#{item}")]) }, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', include_blank: false, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_emoji_reaction_policy'), hint: false, warning_hint: I18n.t('simple_form.hints.defaults.setting_emoji_reaction_policy') + .fields-group + = ff.input :slip_local_emoji_reaction, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_slip_local_emoji_reaction') + - if @dtl_enabled %h4= t 'preferences.dtl' diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index d4c0f41bf8..34a4f5300f 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -289,6 +289,7 @@ en: setting_show_quote_in_public: Show quotes in public timelines setting_simple_timeline_menu: Reduce post menu on timeline setting_single_ref_to_quote: Deliver single reference to other server as quote + setting_slip_local_emoji_reaction: Allow bypassing emoji reaction from local users setting_stay_privacy: Not change privacy after post setting_stop_emoji_reaction_streaming: Disable stamp streamings setting_system_font_ui: Use system's default font diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index a83e78dda5..1d529caff5 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -301,6 +301,7 @@ ja: setting_show_emoji_reaction_on_timeline: タイムライン上に他の人のつけたスタンプを表示する setting_simple_timeline_menu: タイムライン上でメニューの項目を減らす setting_single_ref_to_quote: 参照が1つしかない投稿は、他のサーバーには引用として配信する + setting_slip_local_emoji_reaction: ローカルユーザーに限って上記設定を無視してスタンプを許可する setting_stay_privacy: 投稿時に公開範囲を保存する setting_stop_emoji_reaction_streaming: スタンプのストリーミングを停止する setting_system_font_ui: システムのデフォルトフォントを使う diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 76e91ceb72..80e27c6b36 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -256,7 +256,8 @@ RSpec.describe Account do describe '#allow_emoji_reaction?' do let(:policy) { :allow } - let(:reactioned) { Fabricate(:user, settings: { emoji_reaction_policy: policy }).account } + let(:allow_local) { false } + let(:reactioned) { Fabricate(:user, settings: { emoji_reaction_policy: policy, slip_local_emoji_reaction: allow_local }).account } let(:followee) { Fabricate(:account) } let(:follower) { Fabricate(:account) } let(:mutual) { Fabricate(:account) } @@ -411,6 +412,21 @@ RSpec.describe Account do end end + context 'when policy is block but allow local only' do + let(:policy) { :block } + let(:allow_local) { true } + let(:local) { Fabricate(:user).account } + let(:remote) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') } + + it 'does not allow remote' do + expect(reactioned.allow_emoji_reaction?(remote)).to be false + end + + it 'allows local' do + expect(reactioned.allow_emoji_reaction?(local)).to be true + end + end + context 'when reactioned is remote user' do let(:reactioned) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar/actor', settings: { emoji_reaction_policy: :following_only }) }