about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/lib/feed_manager.rb30
-rw-r--r--app/models/status.rb7
2 files changed, 20 insertions, 17 deletions
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
diff --git a/app/models/status.rb b/app/models/status.rb
index ade8b4c85..e81331e93 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -502,15 +502,14 @@ class Status < ApplicationRecord
       else
         # followers can see followers-only stuff, but also things they are mentioned in.
         # non-followers can see everything that isn't private/direct, but can see stuff they are mentioned in.
-        scope = left_outer_joins(:reblog).published
+        visibility.push(:private) if account.following?(target_account) && user_signed_in
+        scope = left_outer_joins(:reblog)
 
         scope = scope.where(visibility: visibility)
                      .or(scope.where(id: account.mentions.select(:status_id)))
                      .merge(scope.where(reblog_of_id: nil).or(scope.where.not(reblogs_statuses: { account_id: account.excluded_from_timeline_account_ids })))
 
-        scope = scope.or(scope.where(visibility: :private).without_replies) if account.following?(target_account)
-
-        apply_timeline_filters(scope, account, false)
+        apply_timeline_filters(scope.published, account, false)
       end
     end