2019-06-25 21:56:32 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DirectFeed < Feed
|
|
|
|
include Redisable
|
|
|
|
|
|
|
|
def initialize(account)
|
|
|
|
@account = account
|
2023-07-06 11:23:07 +01:00
|
|
|
super(:direct, account.id)
|
2019-06-25 21:56:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
|
|
|
unless redis.exists("account:#{@account.id}:regeneration")
|
|
|
|
statuses = super
|
|
|
|
return statuses unless statuses.empty?
|
|
|
|
end
|
|
|
|
from_database(limit, max_id, since_id, min_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-07-06 11:23:07 +01:00
|
|
|
# TODO: _min_id is not actually handled by `as_direct_timeline`
|
|
|
|
def from_database(limit, max_id, since_id, _min_id)
|
2019-06-25 21:56:32 +01:00
|
|
|
loop do
|
2023-07-06 11:23:07 +01:00
|
|
|
statuses = Status.as_direct_timeline(@account, limit, max_id, since_id)
|
2019-06-25 21:56:32 +01:00
|
|
|
return statuses if statuses.empty?
|
2023-07-06 11:23:07 +01:00
|
|
|
|
2019-06-25 21:56:32 +01:00
|
|
|
max_id = statuses.last.id
|
2021-03-12 21:31:17 +00:00
|
|
|
statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account) }
|
2019-06-25 21:56:32 +01:00
|
|
|
return statuses unless statuses.empty?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|