Add ability to filter individual posts (#18945)
* Add database table for status-specific filters * Add REST endpoints, entities and attributes * Show status filters in /filters interface * Perform server-side filtering for individual posts filters * Fix filtering on context mismatch * Refactor `toServerSideType` by moving it to its own module * Move loupe and delete icons to their own module * Add ability to filter individual posts from WebUI * Replace keyword list by warnings (expired, context mismatch) * Refactor server-side filtering code * Add tests
This commit is contained in:
parent
d156e9b823
commit
50487db122
40 changed files with 1138 additions and 63 deletions
|
@ -47,6 +47,33 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when post is explicitly filtered' do
|
||||
let(:status) { Fabricate(:status, text: 'hello world') }
|
||||
|
||||
before do
|
||||
filter = user.account.custom_filters.create!(phrase: 'filter1', context: %w(home), action: :hide)
|
||||
filter.statuses.create!(status_id: status.id)
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :show, params: { id: status.id }
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns filter information' do
|
||||
get :show, params: { id: status.id }
|
||||
json = body_as_json
|
||||
expect(json[:filtered][0]).to include({
|
||||
filter: a_hash_including({
|
||||
id: user.account.custom_filters.first.id.to_s,
|
||||
title: 'filter1',
|
||||
filter_action: 'hide',
|
||||
}),
|
||||
status_matches: [status.id.to_s],
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'when reblog includes filtered terms' do
|
||||
let(:status) { Fabricate(:status, reblog: Fabricate(:status, text: 'this toot is about that banned word')) }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue