masto-fe/app/javascript/mastodon/features
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
..
account Add limited attribute to accounts in REST API and a warning in web UI (#18344) 2022-05-10 09:44:35 +02:00
account_gallery Add aliases for WebUI routes that were renamed in #16171 (#16772) 2021-09-27 07:23:48 +02:00
account_timeline Add limited attribute to accounts in REST API and a warning in web UI (#18344) 2022-05-10 09:44:35 +02:00
audio Add hotkeys for audio/video control (#15158) 2020-11-15 14:24:54 +01:00
blocks Fix block/mute lists showing a follow button when unblocking a user (#18364) 2022-05-09 23:20:19 +02:00
bookmarked_statuses Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
community_timeline Improve modal flow and back button handling (#16499) 2021-07-13 15:45:17 +02:00
compose Change label of publish button to be "Publish" again (#18583) 2022-06-01 05:03:12 +02:00
direct_timeline Change "Conversations" back to "Direct messages" and add warning in web UI (#18289) 2022-05-03 09:09:09 +02:00
directory Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
domain_blocks Improve modal flow and back button handling (#16499) 2021-07-13 15:45:17 +02:00
emoji Replace deprecated String.prototype.substr() (#17949) 2022-04-04 12:19:45 -04:00
explore Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
favourited_statuses Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
favourites Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
follow_recommendations Fix incorrect use of old WebUI paths (#16773) 2021-09-27 07:24:04 +02:00
follow_requests Change routing paths to use usernames in web UI (#16171) 2021-09-26 05:46:13 +02:00
followers Add limited attribute to accounts in REST API and a warning in web UI (#18344) 2022-05-10 09:44:35 +02:00
following Add limited attribute to accounts in REST API and a warning in web UI (#18344) 2022-05-10 09:44:35 +02:00
generic_not_found Fix performance of home feed regeneration (#12084) 2019-10-06 22:11:17 +02:00
getting_started Change "Conversations" back to "Direct messages" and add warning in web UI (#18289) 2022-05-03 09:09:09 +02:00
hashtag_timeline Fix being able to add more than 4 hashtags to hashtag column in web UI (#17729) 2022-03-09 13:01:44 +01:00
home_timeline Improve modal flow and back button handling (#16499) 2021-07-13 15:45:17 +02:00
keyboard_shortcuts Change "Conversations" back to "Direct messages" and add warning in web UI (#18289) 2022-05-03 09:09:09 +02:00
list_adder Refactor icons in web UI to use Icon component (#9951) 2019-02-01 00:14:05 +01:00
list_editor Disable list title validation button when list title is empty (#11475) 2019-08-03 19:10:39 +02:00
list_timeline Improve modal flow and back button handling (#16499) 2021-07-13 15:45:17 +02:00
lists Change routing paths to use usernames in web UI (#16171) 2021-09-26 05:46:13 +02:00
mutes Fix block/mute lists showing a follow button when unblocking a user (#18364) 2022-05-09 23:20:19 +02:00
notifications Add notifications for new reports (#18697) 2022-06-27 09:30:15 +02:00
picture_in_picture Fix media modal footer's “external link” not being a link (#17561) 2022-02-25 01:20:41 +01:00
pinned_statuses Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
public_timeline Improve modal flow and back button handling (#16499) 2021-07-13 15:45:17 +02:00
reblogs Change "Direct" status visibility to "Only people I mention" in web UI (#18146) 2022-04-29 00:24:31 +02:00
report Fix empty “Server rules violation” report option (#18165) 2022-04-28 21:29:29 +02:00
standalone Add local only to hashtag timeline (#13502) 2020-04-18 21:52:39 +02:00
status Replace leftover envelope icons with at icons (#18305) 2022-05-06 00:41:56 +02:00
ui Revamp post filtering system (#18058) 2022-06-28 09:42:13 +02:00
video Replace deprecated String.prototype.substr() (#17949) 2022-04-04 12:19:45 -04:00