You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
842 B

  1. # frozen_string_literal: true
  2. class DirectFeed < Feed
  3. include Redisable
  4. def initialize(account)
  5. @type = :direct
  6. @id = account.id
  7. @account = account
  8. end
  9. def get(limit, max_id = nil, since_id = nil, min_id = nil)
  10. unless redis.exists("account:#{@account.id}:regeneration")
  11. statuses = super
  12. return statuses unless statuses.empty?
  13. end
  14. from_database(limit, max_id, since_id, min_id)
  15. end
  16. private
  17. def from_database(limit, max_id, since_id, min_id)
  18. loop do
  19. statuses = Status.as_direct_timeline(@account, limit, max_id, since_id, min_id)
  20. return statuses if statuses.empty?
  21. max_id = statuses.last.id
  22. statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account.id) }
  23. return statuses unless statuses.empty?
  24. end
  25. end
  26. end