1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-27 14:29:03 +09:00
YuruToot/app/models/direct_feed.rb
Claire ff168ef202
Fix most rubocop issues (#2165)
* Run rubocop --autocorrect on app/, config/ and lib/, also manually fix some remaining style issues

* Run rubocop --autocorrect-all on db/

* Run rubocop --autocorrect-all on `spec/` and fix remaining issues
2023-04-09 11:25:30 +02:00

33 lines
881 B
Ruby

# frozen_string_literal: true
class DirectFeed < Feed
include Redisable
def initialize(account)
@account = account
super(:direct, account.id)
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
# TODO: _min_id is not actually handled by `as_direct_timeline`
def from_database(limit, max_id, since_id, _min_id)
loop do
statuses = Status.as_direct_timeline(@account, limit, max_id, since_id)
return statuses if statuses.empty?
max_id = statuses.last.id
statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account) }
return statuses unless statuses.empty?
end
end
end