This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2019-06-25 13:56:32 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class DirectFeed < Feed
|
|
|
|
include Redisable
|
|
|
|
|
|
|
|
def initialize(account)
|
|
|
|
@type = :direct
|
|
|
|
@id = account.id
|
|
|
|
@account = account
|
|
|
|
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
|
|
|
|
|
|
|
|
def from_database(limit, max_id, since_id, min_id)
|
|
|
|
loop do
|
|
|
|
statuses = Status.as_direct_timeline(@account, limit, max_id, since_id, min_id)
|
|
|
|
return statuses if statuses.empty?
|
|
|
|
max_id = statuses.last.id
|
2021-03-12 13:31:17 -08:00
|
|
|
statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account) }
|
2019-06-25 13:56:32 -07:00
|
|
|
return statuses unless statuses.empty?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|