Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #636 投稿削除時エラーが出る場合がある問題 #637

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/services/remove_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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?

Expand All @@ -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?

Expand All @@ -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?

Expand Down
12 changes: 12 additions & 0 deletions spec/services/remove_status_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }

Expand Down
Loading