From cdb101340a20183a82889f811d9311c370c855e5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 29 Jun 2018 15:34:36 +0200 Subject: Keyword/phrase filtering (#7905) * Add keyword filtering GET|POST /api/v1/filters GET|PUT|DELETE /api/v1/filters/:id - Irreversible filters can drop toots from home or notifications - Other filters can hide toots through the client app - Filters use a phrase valid in particular contexts, expiration * Make sure expired filters don't get applied client-side * Add missing API methods * Remove "regex filter" from column settings * Add tests * Add test for FeedManager * Add CustomFilter test * Add UI for managing filters * Add streaming API event to allow syncing filters * Fix tests --- config/locales/en.yml | 16 ++++++++++++++++ config/locales/simple_form.en.yml | 6 ++++++ config/navigation.rb | 1 + config/routes.rb | 2 ++ 4 files changed, 25 insertions(+) (limited to 'config') diff --git a/config/locales/en.yml b/config/locales/en.yml index 01e5dd2f8..5cb81ebe9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -474,6 +474,22 @@ en: follows: You follow mutes: You mute storage: Media storage + filters: + contexts: + home: Home timeline + notifications: Notifications + public: Public timelines + thread: Conversations + edit: + title: Edit filter + errors: + invalid_context: None or invalid context supplied + invalid_irreversible: Irreversible filtering only works with home or notifications context + index: + delete: Delete + title: Filters + new: + title: Add new filter followers: domain: Domain explanation_html: If you want to ensure the privacy of your statuses, you must be aware of who is following you. Your private statuses are delivered to all instances where you have followers. You may wish to review them, and remove followers if you do not trust your privacy to be respected by the staff or software of those instances. diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 6783f0045..59133ea73 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -6,17 +6,20 @@ en: autofollow: People who sign up through the invite will automatically follow you avatar: PNG, GIF or JPG. At most 2MB. Will be downscaled to 400x400px bot: This account mainly performs automated actions and might not be monitored + context: One or multiple contexts where the filter should apply digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence display_name: one: 1 character left other: %{count} characters left fields: You can have up to 4 items displayed as a table on your profile header: PNG, GIF or JPG. At most 2MB. Will be downscaled to 700x335px + irreversible: Filtered toots will disappear irreversibly, even if filter is later removed locale: The language of the user interface, e-mails and push notifications locked: Requires you to manually approve followers note: one: 1 character left other: %{count} characters left + phrase: Will be matched regardless of casing in text or content warning of a toot setting_default_language: The language of your toots can be detected automatically, but it's not always accurate setting_hide_network: Who you follow and who follows you will not be shown on your profile setting_noindex: Affects your public profile and status pages @@ -39,6 +42,7 @@ en: chosen_languages: Filter languages confirm_new_password: Confirm new password confirm_password: Confirm password + context: Filter contexts current_password: Current password data: Data display_name: Display name @@ -46,6 +50,7 @@ en: expires_in: Expire after fields: Profile metadata header: Header + irreversible: Drop instead of hide locale: Interface language locked: Lock account max_uses: Max number of uses @@ -53,6 +58,7 @@ en: note: Bio otp_attempt: Two-factor code password: Password + phrase: Keyword or phrase setting_auto_play_gif: Auto-play animated GIFs setting_boost_modal: Show confirmation dialog before boosting setting_default_language: Posting language diff --git a/config/navigation.rb b/config/navigation.rb index 2bee5a4f9..3f2e913c6 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -16,6 +16,7 @@ SimpleNavigation::Configuration.run do |navigation| settings.item :follower_domains, safe_join([fa_icon('users fw'), t('settings.followers')]), settings_follower_domains_url end + primary.item :filters, safe_join([fa_icon('filter fw'), t('filters.index.title')]), filters_path, highlights_on: %r{/filters} primary.item :invites, safe_join([fa_icon('user-plus fw'), t('invites.title')]), invites_path, if: proc { Setting.min_invite_role == 'user' } primary.item :development, safe_join([fa_icon('code fw'), t('settings.development')]), settings_applications_url do |development| diff --git a/config/routes.rb b/config/routes.rb index a3cba24fc..5fdd3b390 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,6 +114,7 @@ Rails.application.routes.draw do resources :tags, only: [:show] resources :emojis, only: [:show] resources :invites, only: [:index, :create, :destroy] + resources :filters, except: [:show] get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy @@ -254,6 +255,7 @@ Rails.application.routes.draw do resources :mutes, only: [:index] resources :favourites, only: [:index] resources :reports, only: [:index, :create] + resources :filters, only: [:index, :create, :show, :update, :destroy] namespace :apps do get :verify_credentials, to: 'credentials#show' -- cgit