diff options
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/lib/status_filter.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 1 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 3 | ||||
-rw-r--r-- | config/locales/simple_form.en.yml | 1 | ||||
-rw-r--r-- | db/migrate/20191221195147_add_filter_timelines_only_to_user.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 3 |
7 files changed, 17 insertions, 5 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 4ac654590..2ff84ac80 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -32,6 +32,7 @@ class Settings::PreferencesController < Settings::BaseController :hide_boosts, :only_known, :invert_filters, + :filter_timelines_only, chosen_languages: [] ) end diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index fb675cbbd..4cb5804da 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -15,9 +15,9 @@ class StatusFilter def filtered? return true if status.nil? || account.nil? return false if !account.nil? && account.id == status.account_id - return !account.user.invert_filters if redis.sismember("filtered_statuses:#{account.id}", status.id) + return !account.user.invert_filters if !account.user.filter_timelines_only && redis.sismember("filtered_statuses:#{account.id}", status.id) if blocked_by_policy? || (account_present? && filtered_status?) || silenced_account? - redis.sadd("filtered_statuses:#{account.id}", status.id) + redis.sadd("filtered_statuses:#{account.id}", status.id) unless account.user.filter_timelines_only return true end false @@ -40,7 +40,7 @@ class StatusFilter return true if account.user_hides_replies_of_blocker? && reply_to_blocker? # filtered by user? - return true if !account.user.invert_filters && phrase_filtered?(status, account.id) + return true if !account.user.filter_timelines_only && !account.user.invert_filters && phrase_filtered?(status, account.id) # kajiht has no filters if status has no mentions return false if status&.mentions.blank? @@ -77,7 +77,7 @@ class StatusFilter return true if !@preloaded_relations[:following] && (mentioned_account_ids - account.following_ids).any? # filtered by user? - account.user.invert_filters && !phrase_filtered?(status, account.id) + !account.user.filter_timelines_only && account.user.invert_filters && !phrase_filtered?(status, account.id) end def reply_to_blocked? diff --git a/app/models/user.rb b/app/models/user.rb index f6e1a369d..2ee304e81 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,6 +42,7 @@ # hide_boosts :boolean # only_known :boolean # invert_filters :boolean default(FALSE), not null +# filter_timelines_only :boolean default(FALSE), not null # class User < ApplicationRecord diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 8f4563fde..80ad6c109 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -47,6 +47,9 @@ .fields-group = f.input :invert_filters, as: :boolean, wrapper: :with_label + = f.input :filter_timelines_only, as: :boolean, wrapper: :with_label + + .fields-group = f.input :setting_rawr_federated, as: :boolean, wrapper: :with_label = f.input :hide_boosts, as: :boolean, wrapper: :with_label = f.input :only_known, as: :boolean, wrapper: :with_label diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index cb106082d..9c34a1071 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -183,6 +183,7 @@ en: hide_boosts: Don't show boosts on any timeline only_known: Only show posts from packmates on all timelines invert_filters: Use allow list mode for filters + filter_timelines_only: Apply filters to timelines only severity: Severity type: Import type username: Username diff --git a/db/migrate/20191221195147_add_filter_timelines_only_to_user.rb b/db/migrate/20191221195147_add_filter_timelines_only_to_user.rb new file mode 100644 index 000000000..ba9135273 --- /dev/null +++ b/db/migrate/20191221195147_add_filter_timelines_only_to_user.rb @@ -0,0 +1,5 @@ +class AddFilterTimelinesOnlyToUser < ActiveRecord::Migration[5.2] + def change + add_column :users, :filter_timelines_only, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 631469a2a..eb3b879a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_12_21_183232) do +ActiveRecord::Schema.define(version: 2019_12_21_195147) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -811,6 +811,7 @@ ActiveRecord::Schema.define(version: 2019_12_21_183232) do t.boolean "hide_boosts" t.boolean "only_known" t.boolean "invert_filters", default: false, null: false + t.boolean "filter_timelines_only", default: false, null: false t.index ["account_id"], name: "index_users_on_account_id" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id" |