diff --git a/app/models/feed.rb b/app/models/feed.rb index 5bce88f25522df..492ddc652a4980 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -13,6 +13,12 @@ def get(limit, max_id = nil, since_id = nil, min_id = nil) protected def from_redis(limit, max_id, since_id, min_id) + # 1ヶ月以上前へ遡ろうとする行為を全面的に禁止 + oldest_id = 1.month.ago.to_i * 1000 << 16 + max_id = [max_id.to_i, oldest_id].min if max_id.present? + since_id = [since_id.to_i, oldest_id].max if since_id.present? + min_id = [min_id.to_i, oldest_id].max if min_id.present? + if min_id.blank? max_id = '+inf' if max_id.blank? since_id = '-inf' if since_id.blank? diff --git a/app/models/home_feed.rb b/app/models/home_feed.rb index ba7564983b0f8b..deef3006be5ed9 100644 --- a/app/models/home_feed.rb +++ b/app/models/home_feed.rb @@ -18,6 +18,12 @@ def get(limit, max_id = nil, since_id = nil, min_id = nil) private def from_database(limit, max_id, since_id, min_id) + # 1ヶ月以上前へ遡ろうとする行為を全面的に禁止 + oldest_id = 1.month.ago.to_i * 1000 << 16 + max_id = [max_id.to_i, oldest_id].min if max_id.present? + since_id = [since_id.to_i, oldest_id].max if since_id.present? + min_id = [min_id.to_i, oldest_id].max if min_id.present? + Status.as_home_timeline(@account) .paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id) .reject { |status| FeedManager.instance.filter?(:home, status, @account.id) }