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 1cfd9a500..a987bb72c 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
   def initialize(account, options = {})
     @account = account
     @options = options
@@ -21,6 +22,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?
@@ -36,6 +38,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
@@ -56,6 +62,10 @@ class PublicFeed
     account.present?
   end
 
+  def local_account?
+    account&.local?
+  end
+
   def media_only?
     options[:only_media]
   end
@@ -84,6 +94,10 @@ class PublicFeed
     Status.joins(:media_attachments).group(:id)
   end
 
+  def without_local_only_scope
+    Status.not_local_only
+  end
+
   def language_scope
     Status.where(language: account.chosen_languages)
   end