From cd5fadcd8d9df4a12e984cfc43193571dae5bdae Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Tue, 11 Aug 2020 16:27:47 -0500 Subject: [Privacy, Timelines] Improve filtering --- app/lib/feed_manager.rb | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'app/lib') diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 0708fb35f..0ec341e3f 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -244,37 +244,41 @@ class FeedManager def filter_from_home?(status, receiver_id, crutches) return false if receiver_id == status.account_id - return true unless status.published? + return true unless status.published? && (status.conversation&.public? || crutches[:following][status.conversation&.account_id]) return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?) return true if phrase_filtered?(status, receiver_id, :home) check_for_blocks = crutches[:active_mentions][status.id] || [] check_for_blocks.concat([status.account_id]) check_for_blocks.concat([status.conversation.account_id]) unless status.conversation&.account_id.nil? - check_for_blocks.concat([[status.in_reply_to_account_id]]) if status.reply? + check_for_blocks.concat([status.in_reply_to_account_id]) if status.reply? if status.reblog? check_for_blocks.concat([status.reblog.account_id]) check_for_blocks.concat(crutches[:active_mentions][status.reblog_of_id] || []) check_for_blocks.concat([status.reblog.conversation.account_id]) unless status.reblog.conversation&.account_id.nil? - check_for_blocks.concat([[status.reblog.in_reply_to_account_id]]) if status.reblog.reply? + check_for_blocks.concat([status.reblog.in_reply_to_account_id]) if status.reblog.reply? end return true if check_for_blocks.any? { |target_account_id| crutches[:blocking][target_account_id] || crutches[:muting][target_account_id] } - if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply - should_filter = !crutches[:following][status.in_reply_to_account_id] # and I'm not following the person it's a reply to - should_filter &&= !crutches[:following][status.conversation&.account_id] # and I'm not following the thread owner - should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me - should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply + if status.reply? && !status.in_reply_to_account_id.nil? + should_filter = receiver_id != status.in_reply_to_account_id + should_filter &&= status.account_id != status.in_reply_to_account_id + should_filter &&= !(crutches[:following][status.in_reply_to_account_id] && crutches[:following][status.conversation&.account_id]) return !!should_filter - elsif status.reblog? # Filter out a reblog - return true if status.reblog.account.silenced? # if the author is silenced + elsif status.reblog? + should_filter = status.reblog.reply? + should_filter &&= status.reblog.account_id != status.reblog.in_reply_to_account_id + should_filter &&= !(crutches[:following][status.reblog.in_reply_to_account_id] && crutches[:following][status.reblog.conversation&.account_id]) - should_filter = crutches[:hiding_reblogs][status.account_id] # if the reblogger's reblogs are suppressed - should_filter ||= crutches[:blocked_by][status.reblog.account_id] # or if the author of the reblogged status is blocking me - should_filter ||= crutches[:domain_blocking][status.reblog.account.domain] # or the author's domain is blocked + should_filter ||= !crutches[:following][status.reblog.account_id] if status.reblog.account.silenced? + should_filter ||= !crutches[:following][status.reblog.conversation&.account_id] if status.reblog.conversation&.account&.silenced? + + should_filter ||= crutches[:hiding_reblogs][status.account_id] + should_filter ||= crutches[:blocked_by][status.reblog.account_id] + should_filter ||= crutches[:domain_blocking][status.reblog.account.domain] return !!should_filter end -- cgit