From 53018b144f873b528bb56e93c5a50e4765397259 Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 5 Mar 2024 19:54:37 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20#636=20=E6=8A=95=E7=A8=BF=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E6=99=82=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F?= =?UTF-8?q?=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/remove_status_service.rb | 9 ++++++--- spec/services/remove_status_service_spec.rb | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 45295898f352d0..d5ef41b19d2061 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -19,6 +19,9 @@ def call(status, **options) @account = status.account @options = options + @visibility = @status.visibility&.to_sym || :public + @searchability = @status.searchability&.to_sym || @status.compute_searchability&.to_sym || :public + with_redis_lock("distribute:#{@status.id}") do @status.discard_with_reblogs @@ -146,7 +149,7 @@ def remove_from_hashtags featured_tag.decrement(@status.id) end - return unless %i(public public_unlisted login).include?(@status.visibility.to_sym) || (@status.unlisted_visibility? && %i(public public_unlisted).include?(@status.searchability.to_sym)) + return unless %i(public public_unlisted login).include?(@visibility) || (@status.unlisted_visibility? && %i(public public_unlisted).include?(@searchability)) return if skip_streaming? @@ -157,7 +160,7 @@ def remove_from_hashtags end def remove_from_public - return unless %i(public public_unlisted login).include?(@status.visibility.to_sym) + return unless %i(public public_unlisted login).include?(@visibility) return if skip_streaming? @@ -166,7 +169,7 @@ def remove_from_public end def remove_from_media - return unless %i(public public_unlisted login).include?(@status.visibility.to_sym) + return unless %i(public public_unlisted login).include?(@visibility) return if skip_streaming? diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index dd88f047a19f06..65ac785c04f1b6 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -83,6 +83,18 @@ end end + context 'when removed status is null-searchability' do + let(:status) { PostStatusService.new.call(alice, visibility: 'unlisted', text: 'Public post') } + + before do + status.update!(searchability: nil) + end + + it 'does not throw error' do + expect { subject.call(status) }.to_not raise_error + end + end + context 'when removed status is limited' do let(:status) { PostStatusService.new.call(alice, visibility: 'mutual', text: 'limited post') }