You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mastodon/app/controllers
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.
3 years ago
..
activitypub Fix suspended users being able to access APIs that don't require a user (#18524) 3 years ago
admin Add administrative webhooks (#18510) 3 years ago
api Revamp post filtering system (#18058) 3 years ago
auth Fix suspicious sign-in mails never being sent (#18599) 3 years ago
concerns Remove sign-in token authentication, instead send e-mail about new sign-in (#17970) 3 years ago
disputes Change old moderation strikes to be displayed in a separate page (#17566) 3 years ago
oauth Fix error when trying to revoke OAuth token without supplying a token (#18205) 3 years ago
settings Refactor how Redis locks are created (#18400) 3 years ago
well_known Remove Keybase integration (#17045) 3 years ago
about_controller.rb Add server rules (#15769) 4 years ago
account_follow_controller.rb Add specific rate limits for posting and following (#13172) 5 years ago
account_unfollow_controller.rb
accounts_controller.rb Change RSS feeds (#18356) 3 years ago
application_controller.rb Add logging of S3-related errors (#16381) 4 years ago
authorize_interactions_controller.rb Fix double render error when authorizing interaction (#18203) 3 years ago
custom_css_controller.rb Remove set-cookie header on custom.css (#16314) 4 years ago
directories_controller.rb Change trending hashtags to be affected be reblogs (#16164) 4 years ago
emojis_controller.rb Add (back) rails-level JSON caching (#11333) 6 years ago
filters_controller.rb Revamp post filtering system (#18058) 3 years ago
follower_accounts_controller.rb Add `/api/v1/accounts/familiar_followers` to REST API (#17700) 3 years ago
following_accounts_controller.rb Fix double render error when authorizing interaction (#18203) 3 years ago
health_controller.rb Change health check (#15988) 4 years ago
home_controller.rb Change routing paths to use usernames in web UI (#16171) 4 years ago
instance_actors_controller.rb Fix instance actor not being dereferenceable (#17457) 3 years ago
intents_controller.rb Refactor controllers for statuses, accounts, and more (#11249) 6 years ago
invites_controller.rb Add invite comments (#10465) 6 years ago
manifests_controller.rb Fix redirecting non-functional accounts on public pages (#11978) 6 years ago
media_controller.rb Fix error when rendering public pages with media attachments (#16763) 3 years ago
media_proxy_controller.rb Refactor how Redis locks are created (#18400) 3 years ago
public_timelines_controller.rb Fix blurhash and autoplay not working on public pages (#11585) 6 years ago
relationships_controller.rb Add interrelationship icon (#15149) 4 years ago
remote_follow_controller.rb Fix redirecting non-functional accounts on public pages (#11978) 6 years ago
remote_interaction_controller.rb Fix functional user requirements in whitelist mode (#14093) 5 years ago
shares_controller.rb Fix blurhash and autoplay not working on public pages (#11585) 6 years ago
statuses_cleanup_controller.rb Add feature to automatically delete old toots (#16529) 4 years ago
statuses_controller.rb Fix error when trying to render component for media without meta (#16112) 4 years ago
tags_controller.rb Change RSS feeds (#18356) 3 years ago