2017-11-18 01:16:48 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class HomeFeed < Feed
|
|
|
|
def initialize(account)
|
|
|
|
@type = :home
|
|
|
|
@id = account.id
|
|
|
|
@account = account
|
|
|
|
end
|
|
|
|
|
2018-09-28 03:23:45 +03:00
|
|
|
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
2017-11-18 01:16:48 +02:00
|
|
|
if redis.exists("account:#{@account.id}:regeneration")
|
2018-09-28 03:23:45 +03:00
|
|
|
from_database(limit, max_id, since_id, min_id)
|
2017-11-18 01:16:48 +02:00
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-09-28 03:23:45 +03:00
|
|
|
def from_database(limit, max_id, since_id, min_id)
|
2017-11-18 01:16:48 +02:00
|
|
|
Status.as_home_timeline(@account)
|
2018-09-28 03:23:45 +03:00
|
|
|
.paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
|
2017-11-18 01:16:48 +02:00
|
|
|
.reject { |status| FeedManager.instance.filter?(:home, status, @account.id) }
|
|
|
|
end
|
|
|
|
end
|