mastodon/app/javascript/mastodon
Claire 02851848e9
Revamp post filtering system (#18058)
* Add model for custom filter keywords

* Use CustomFilterKeyword internally

Does not change the API

* Fix /filters/edit and /filters/new

* Add migration tests

* Remove whole_word column from custom_filters (covered by custom_filter_keywords)

* Redesign /filters

Instead of a list, present a card that displays more information and handles
multiple keywords per filter.

* Redesign /filters/new and /filters/edit to add and remove keywords

This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.

* Add /api/v2/filters to edit filter with multiple keywords

Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
  `keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`

API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
  `keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
  `keywords_attributes` can also be passed to edit, delete or add keywords in
   one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
   filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword

* Change from `irreversible` boolean to `action` enum

* Remove irrelevent `irreversible_must_be_within_context` check

* Fix /filters/new and /filters/edit with update for filter_action

* Fix Rubocop/Codeclimate complaining about task names

* Refactor FeedManager#phrase_filtered?

This moves regexp building and filter caching to the `CustomFilter` class.

This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.

* Perform server-side filtering and output result in REST API

* Fix numerous filters_changed events being sent when editing multiple keywords at once

* Add some tests

* Use the new API in the WebUI

- use client-side logic for filters we have fetched rules for.
  This is so that filter changes can be retroactively applied without
  reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
  (e.g. network error, or initial timeline loading)

* Minor optimizations and refactoring

* Perform server-side filtering on the streaming server

* Change the wording of filter action labels

* Fix issues pointed out by linter

* Change design of “Show anyway” link in accordence to review comments

* Drop “irreversible” filtering behavior

* Move /api/v2/filter_keywords to /api/v1/filters/keywords

* Rename `filter_results` attribute to `filtered`

* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer

* Fix systemChannelId value in streaming server

* Simplify code by removing client-side filtering code

The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.
2022-06-28 09:42:13 +02:00
..
actions Revamp post filtering system (#18058) 2022-06-28 09:42:13 +02:00
components Revamp post filtering system (#18058) 2022-06-28 09:42:13 +02:00
containers Spelling (#17705) 2022-03-06 22:51:40 +01:00
features Revamp post filtering system (#18058) 2022-06-28 09:42:13 +02:00
locales Add notifications for new reports (#18697) 2022-06-27 09:30:15 +02:00
middleware Fix 404 and 410 API errors being silently discarded in WebUI (#13279) 2020-03-28 17:59:45 +01:00
reducers Revamp post filtering system (#18058) 2022-06-28 09:42:13 +02:00
selectors Revamp post filtering system (#18058) 2022-06-28 09:42:13 +02:00
service_worker Add notifications for new sign-ups (#16953) 2022-02-23 16:45:22 +01:00
storage Cache media only when storage can be freed (#7547) 2018-05-19 19:22:11 +02:00
store Code style improvements in JavaScript (#13159) 2020-03-08 16:02:36 +01:00
utils Add support for webp uploads (#18506) 2022-05-27 20:06:40 +02:00
api.js Change routing paths to use usernames in web UI (#16171) 2021-09-26 05:46:13 +02:00
base_polyfills.js Fix old browsers crashing because of missing finally polyfill in web UI (#13115) 2020-02-18 17:22:44 +01:00
blurhash.js Fix not being able to open audio modal in web UI (#15283) 2020-12-07 04:29:37 +01:00
common.js Migrate Rails ujs as required for Rails 6 Upgrade. (#13280) 2020-03-21 03:14:50 +01:00
compare_id.js Add option to disable real-time updates in web UI (#9984) 2019-07-16 06:30:47 +02:00
extra_polyfills.js fix multiple space (#12655) 2019-12-19 07:39:08 +09:00
initial_state.js Add language dropdown to compose in web UI (#18420) 2022-05-16 11:18:35 +02:00
is_mobile.js Fix pop-out player appearing on mobile screens in web UI (#15157) 2020-11-16 05:16:39 +01:00
load_keyboard_extensions.js fix: support KaiOS arrow navigation on public pages (#12251) 2019-11-04 13:03:09 +01:00
load_polyfills.js Fix old browsers crashing because of missing finally polyfill in web UI (#13115) 2020-02-18 17:22:44 +01:00
main.js Fix browser notification permission request logic (#13543) 2020-10-13 00:37:21 +02:00
performance.js Upgrade to React 16 (#5119) 2017-09-30 04:29:56 +02:00
ready.js Do not load unnecessary script files (#4193) 2017-07-14 11:08:56 +02:00
scroll.js Use ScrollToOptions for smooth scrolling if supported (#11207) 2019-06-29 18:32:06 +02:00
settings.js Implement tag auto-completion by history (#6621) 2018-03-04 20:27:25 +01:00
stream.js Fixed ESLint error (#15214) 2020-11-23 17:35:14 +01:00
test_setup.js Replace to testing-library from enzyme (#14152) 2020-06-29 13:58:07 +02:00
uuid.js Replace sprockets/browserify with Webpack (#2617) 2017-05-03 02:04:16 +02:00