about summary refs log tree commit diff
path: root/app/models/public_feed.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/public_feed.rb')
-rw-r--r--app/models/public_feed.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/public_feed.rb b/app/models/public_feed.rb
index 2cf9206d2..bc8281ef2 100644
--- a/app/models/public_feed.rb
+++ b/app/models/public_feed.rb
@@ -8,6 +8,7 @@ class PublicFeed
   # @option [Boolean] :local
   # @option [Boolean] :remote
   # @option [Boolean] :only_media
+  # @option [Boolean] :allow_local_only
   # @option [String]  :locale
   def initialize(account, options = {})
     @account = account
@@ -22,6 +23,7 @@ class PublicFeed
   def get(limit, max_id = nil, since_id = nil, min_id = nil)
     scope = public_scope
 
+    scope.merge!(without_local_only_scope) unless allow_local_only?
     scope.merge!(without_replies_scope) unless with_replies?
     scope.merge!(without_reblogs_scope) unless with_reblogs?
     scope.merge!(local_only_scope) if local_only?
@@ -37,6 +39,10 @@ class PublicFeed
 
   attr_reader :account, :options
 
+  def allow_local_only?
+    local_account? && (local_only? || options[:allow_local_only])
+  end
+
   def with_reblogs?
     options[:with_reblogs]
   end
@@ -57,6 +63,10 @@ class PublicFeed
     account.present?
   end
 
+  def local_account?
+    account&.local?
+  end
+
   def media_only?
     options[:only_media]
   end
@@ -85,6 +95,10 @@ class PublicFeed
     Status.joins(:media_attachments).group(:id)
   end
 
+  def without_local_only_scope
+    Status.not_local_only
+  end
+
   def language_scope
     if account&.chosen_languages.present?
       Status.where(language: account.chosen_languages)