mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-29 10:53:39 +00:00
Fix tootctl status remove removing quoted posts and remote quotes of local posts
This commit is contained in:
parent
76d8ac3fe6
commit
815f5ccd8f
|
|
@ -62,6 +62,8 @@ module Mastodon::CLI
|
|||
AND NOT EXISTS (SELECT 1 FROM mentions WHERE statuses.id = mentions.status_id AND mentions.account_id IN (SELECT accounts.id FROM accounts WHERE domain IS NULL))
|
||||
AND NOT EXISTS (SELECT 1 FROM favourites WHERE statuses.id = favourites.status_id AND favourites.account_id IN (SELECT accounts.id FROM accounts WHERE domain IS NULL))
|
||||
AND NOT EXISTS (SELECT 1 FROM bookmarks WHERE statuses.id = bookmarks.status_id AND bookmarks.account_id IN (SELECT accounts.id FROM accounts WHERE domain IS NULL))
|
||||
AND NOT EXISTS (SELECT 1 FROM quotes JOIN statuses statuses1 ON quotes.status_id = statuses1.id WHERE quotes.quoted_status_id = statuses.id AND (statuses1.uri IS NULL OR statuses1.local))
|
||||
AND NOT EXISTS (SELECT 1 FROM quotes JOIN statuses statuses1 ON quotes.quoted_status_id = statuses1.id WHERE quotes.status_id = statuses.id AND (statuses1.uri IS NULL OR statuses1.local))
|
||||
#{clean_followed_sql}
|
||||
SQL
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,26 @@ RSpec.describe Mastodon::CLI::Statuses do
|
|||
describe '#remove', use_transactional_tests: false do
|
||||
let(:action) { :remove }
|
||||
|
||||
let(:local_account) { Fabricate(:account) }
|
||||
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
let(:followed_remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
let!(:local_status) { Fabricate(:status, created_at: 1.year.ago) }
|
||||
let!(:irrelevant_status) { Fabricate(:status, account: remote_account, created_at: 1.year.ago) }
|
||||
let!(:followed_status) { Fabricate(:status, account: followed_remote_account, created_at: 1.year.ago) }
|
||||
let!(:status_with_local_reply) { Fabricate(:status, account: remote_account, created_at: 1.year.ago) }
|
||||
let!(:local_reply) { Fabricate(:status, thread: status_with_local_reply, created_at: 1.year.ago) }
|
||||
let!(:irrelevant_quote) { Fabricate(:status, account: remote_account, created_at: 1.year.ago) }
|
||||
let!(:quote_of_local) { Fabricate(:status, account: remote_account, created_at: 1.year.ago) }
|
||||
let!(:quoted_by_local) { Fabricate(:status, account: remote_account, created_at: 1.year.ago) }
|
||||
let!(:local_quote) { Fabricate(:status, created_at: 1.year.ago) }
|
||||
|
||||
before do
|
||||
local_account.follow!(followed_remote_account)
|
||||
Fabricate(:quote, status: irrelevant_quote, quoted_status: irrelevant_status, state: :accepted)
|
||||
Fabricate(:quote, status: quote_of_local, quoted_status: local_status, state: :accepted)
|
||||
Fabricate(:quote, status: local_quote, quoted_status: quoted_by_local, state: :accepted)
|
||||
end
|
||||
|
||||
context 'with small batch size' do
|
||||
let(:options) { { batch_size: 0 } }
|
||||
|
||||
|
|
@ -28,6 +48,10 @@ RSpec.describe Mastodon::CLI::Statuses do
|
|||
it 'removes unreferenced statuses' do
|
||||
expect { subject }
|
||||
.to output_results('Done after')
|
||||
|
||||
expect(Status.all)
|
||||
.to include(local_status, followed_status, local_reply, status_with_local_reply, quote_of_local, quoted_by_local, local_quote)
|
||||
.and not_include(irrelevant_status, irrelevant_quote)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user