add option to only apply phrase filters to timelines

master
multiple creatures 2019-12-21 13:59:38 -06:00
parent 8312a6e510
commit 5f92c6429f
7 changed files with 17 additions and 5 deletions

View File

@ -32,6 +32,7 @@ class Settings::PreferencesController < Settings::BaseController
:hide_boosts,
:only_known,
:invert_filters,
:filter_timelines_only,
chosen_languages: []
)
end

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"