From 5d1b90b805b8116d435133b50d5f77e26ea2aa98 Mon Sep 17 00:00:00 2001 From: Sho Kusano Date: Fri, 26 Apr 2019 00:39:45 +0900 Subject: [PATCH] Do not trace back timeline --- app/models/feed.rb | 6 ++++++ app/models/home_feed.rb | 6 ++++++ 2 files changed, 12 insertions(+) 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) }