about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb6
-rw-r--r--app/models/user.rb10
2 files changed, 15 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 5f8680820..7f4066036 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -183,6 +183,7 @@ class Status < ApplicationRecord
     0, 1, 2, 3, 5, 10, 15, 30, 60, 120, 180, 360, 720, 1440, 2880, 4320, 7200,
     10_080, 20_160, 30_240, 60_480, 120_960, 181_440, 241_920, 362_880, 524_160
   ].freeze
+  HISTORY_VALUES = [0, 1, 2, 3, 6, 12, 18, 24, 36, 52, 104, 156].freeze
 
   def searchable_by(preloaded = nil)
     ids = []
@@ -571,6 +572,11 @@ class Status < ApplicationRecord
         end
       end
 
+      if target_account.id != account&.id && target_account&.user&.max_history_public.present?
+        history_limit = account.following?(target_account) ? target_account.user.max_history_private : target_account.user.max_history_public
+        query = query.where('statuses.updated_at >= ?', history_limit.weeks.ago) if history_limit.positive?
+      end
+
       return query if options[:tag].blank?
 
       (tag = Tag.find_normalized(options[:tag])) ? query.merge(Status.tagged_with(tag.id)) : none
diff --git a/app/models/user.rb b/app/models/user.rb
index f9a0df46f..c494aa7a5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -124,7 +124,7 @@ class User < ApplicationRecord
            :style_wide_media,
            :publish_in, :unpublish_in, :unpublish_delete, :boost_every, :boost_jitter,
            :boost_random, :unpublish_on_delete, :rss_disabled, :no_boosts_home,
-           :filter_unknown,
+           :filter_unknown, :max_history_public, :max_history_private,
            to: :settings, prefix: :setting, allow_nil: false
 
   attr_reader :invite_code, :sign_in_token_attempt
@@ -271,6 +271,14 @@ class User < ApplicationRecord
     @filters_unknown ||= settings.filter_unknown
   end
 
+  def max_history_private
+    @max_history_private ||= settings.max_history_private.to_i
+  end
+
+  def max_history_public
+    @max_history_public ||= [settings.max_history_public.to_i, max_history_private].min
+  end
+
   # rubocop:disable Naming/MethodParameterName
   def token_for_app(a)
     return nil if a.nil? || a.owner != self