feed_manager.rb 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. # frozen_string_literal: true
  2. require 'singleton'
  3. class FeedManager
  4. include Singleton
  5. include Redisable
  6. # Maximum number of items stored in a single feed
  7. MAX_ITEMS = 400
  8. # Number of items in the feed since last reblog of status
  9. # before the new reblog will be inserted. Must be <= MAX_ITEMS
  10. # or the tracking sets will grow forever
  11. REBLOG_FALLOFF = 40
  12. # Execute block for every active account
  13. # @yield [Account]
  14. # @return [void]
  15. def with_active_accounts(&block)
  16. Account.joins(:user).where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago).find_each(&block)
  17. end
  18. # Redis key of a feed
  19. # @param [Symbol] type
  20. # @param [Integer] id
  21. # @param [Symbol] subtype
  22. # @return [String]
  23. def key(type, id, subtype = nil)
  24. return "feed:#{type}:#{id}" unless subtype
  25. "feed:#{type}:#{id}:#{subtype}"
  26. end
  27. # Check if the status should not be added to a feed
  28. # @param [Symbol] timeline_type
  29. # @param [Status] status
  30. # @param [Account|List] receiver
  31. # @return [Boolean]
  32. def filter?(timeline_type, status, receiver)
  33. case timeline_type
  34. when :home
  35. filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]))
  36. when :list
  37. filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]))
  38. when :mentions
  39. filter_from_mentions?(status, receiver.id)
  40. else
  41. false
  42. end
  43. end
  44. # Add a status to a home feed and send a streaming API update
  45. # @param [Account] account
  46. # @param [Status] status
  47. # @param [Boolean] update
  48. # @return [Boolean]
  49. def push_to_home(account, status, update: false)
  50. return false unless add_to_feed(:home, account.id, status, account.user&.aggregates_reblogs?)
  51. trim(:home, account.id)
  52. PushUpdateWorker.perform_async(account.id, status.id, "timeline:#{account.id}", { 'update' => update }) if push_update_required?("timeline:#{account.id}")
  53. true
  54. end
  55. # Remove a status from a home feed and send a streaming API update
  56. # @param [Account] account
  57. # @param [Status] status
  58. # @param [Boolean] update
  59. # @return [Boolean]
  60. def unpush_from_home(account, status, update: false)
  61. return false unless remove_from_feed(:home, account.id, status, account.user&.aggregates_reblogs?)
  62. redis.publish("timeline:#{account.id}", Oj.dump(event: :delete, payload: status.id.to_s)) unless update
  63. true
  64. end
  65. # Add a status to a list feed and send a streaming API update
  66. # @param [List] list
  67. # @param [Status] status
  68. # @param [Boolean] update
  69. # @return [Boolean]
  70. def push_to_list(list, status, update: false)
  71. return false if filter_from_list?(status, list) || !add_to_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?)
  72. trim(:list, list.id)
  73. PushUpdateWorker.perform_async(list.account_id, status.id, "timeline:list:#{list.id}", { 'update' => update }) if push_update_required?("timeline:list:#{list.id}")
  74. true
  75. end
  76. # Remove a status from a list feed and send a streaming API update
  77. # @param [List] list
  78. # @param [Status] status
  79. # @param [Boolean] update
  80. # @return [Boolean]
  81. def unpush_from_list(list, status, update: false)
  82. return false unless remove_from_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?)
  83. redis.publish("timeline:list:#{list.id}", Oj.dump(event: :delete, payload: status.id.to_s)) unless update
  84. true
  85. end
  86. # Fill a home feed with an account's statuses
  87. # @param [Account] from_account
  88. # @param [Account] into_account
  89. # @return [void]
  90. def merge_into_home(from_account, into_account)
  91. timeline_key = key(:home, into_account.id)
  92. aggregate = into_account.user&.aggregates_reblogs?
  93. query = from_account.statuses.where(visibility: [:public, :unlisted, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
  94. if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
  95. oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
  96. query = query.where('id > ?', oldest_home_score)
  97. end
  98. statuses = query.to_a
  99. crutches = build_crutches(into_account.id, statuses)
  100. statuses.each do |status|
  101. next if filter_from_home?(status, into_account.id, crutches)
  102. add_to_feed(:home, into_account.id, status, aggregate)
  103. end
  104. trim(:home, into_account.id)
  105. end
  106. # Fill a list feed with an account's statuses
  107. # @param [Account] from_account
  108. # @param [List] list
  109. # @return [void]
  110. def merge_into_list(from_account, list)
  111. timeline_key = key(:list, list.id)
  112. aggregate = list.account.user&.aggregates_reblogs?
  113. query = from_account.statuses.where(visibility: [:public, :unlisted, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
  114. if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
  115. oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
  116. query = query.where('id > ?', oldest_home_score)
  117. end
  118. statuses = query.to_a
  119. crutches = build_crutches(list.account_id, statuses)
  120. statuses.each do |status|
  121. next if filter_from_home?(status, list.account_id, crutches) || filter_from_list?(status, list)
  122. add_to_feed(:list, list.id, status, aggregate)
  123. end
  124. trim(:list, list.id)
  125. end
  126. # Remove an account's statuses from a home feed
  127. # @param [Account] from_account
  128. # @param [Account] into_account
  129. # @return [void]
  130. def unmerge_from_home(from_account, into_account)
  131. timeline_key = key(:home, into_account.id)
  132. timeline_status_ids = redis.zrange(timeline_key, 0, -1)
  133. from_account.statuses.select('id, reblog_of_id').where(id: timeline_status_ids).reorder(nil).find_each do |status|
  134. remove_from_feed(:home, into_account.id, status, into_account.user&.aggregates_reblogs?)
  135. end
  136. end
  137. # Remove an account's statuses from a list feed
  138. # @param [Account] from_account
  139. # @param [List] list
  140. # @return [void]
  141. def unmerge_from_list(from_account, list)
  142. timeline_key = key(:list, list.id)
  143. timeline_status_ids = redis.zrange(timeline_key, 0, -1)
  144. from_account.statuses.select('id, reblog_of_id').where(id: timeline_status_ids).reorder(nil).find_each do |status|
  145. remove_from_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?)
  146. end
  147. end
  148. # Clear all statuses from or mentioning target_account from a home feed
  149. # @param [Account] account
  150. # @param [Account] target_account
  151. # @return [void]
  152. def clear_from_home(account, target_account)
  153. timeline_key = key(:home, account.id)
  154. timeline_status_ids = redis.zrange(timeline_key, 0, -1)
  155. statuses = Status.where(id: timeline_status_ids).select(:id, :reblog_of_id, :account_id).to_a
  156. reblogged_ids = Status.where(id: statuses.map(&:reblog_of_id).compact, account: target_account).pluck(:id)
  157. with_mentions_ids = Mention.active.where(status_id: statuses.flat_map { |s| [s.id, s.reblog_of_id] }.compact, account: target_account).pluck(:status_id)
  158. target_statuses = statuses.select do |status|
  159. status.account_id == target_account.id || reblogged_ids.include?(status.reblog_of_id) || with_mentions_ids.include?(status.id) || with_mentions_ids.include?(status.reblog_of_id)
  160. end
  161. target_statuses.each do |status|
  162. unpush_from_home(account, status)
  163. end
  164. end
  165. # Clear all statuses from or mentioning target_account from a list feed
  166. # @param [List] list
  167. # @param [Account] target_account
  168. # @return [void]
  169. def clear_from_list(list, target_account)
  170. timeline_key = key(:list, list.id)
  171. timeline_status_ids = redis.zrange(timeline_key, 0, -1)
  172. statuses = Status.where(id: timeline_status_ids).select(:id, :reblog_of_id, :account_id).to_a
  173. reblogged_ids = Status.where(id: statuses.map(&:reblog_of_id).compact, account: target_account).pluck(:id)
  174. with_mentions_ids = Mention.active.where(status_id: statuses.flat_map { |s| [s.id, s.reblog_of_id] }.compact, account: target_account).pluck(:status_id)
  175. target_statuses = statuses.select do |status|
  176. status.account_id == target_account.id || reblogged_ids.include?(status.reblog_of_id) || with_mentions_ids.include?(status.id) || with_mentions_ids.include?(status.reblog_of_id)
  177. end
  178. target_statuses.each do |status|
  179. unpush_from_list(list, status)
  180. end
  181. end
  182. # Clear all statuses from or mentioning target_account from an account's lists
  183. # @param [Account] account
  184. # @param [Account] target_account
  185. # @return [void]
  186. def clear_from_lists(account, target_account)
  187. List.where(account: account).each do |list|
  188. clear_from_list(list, target_account)
  189. end
  190. end
  191. # Populate home feed of account from scratch
  192. # @param [Account] account
  193. # @return [void]
  194. def populate_home(account)
  195. limit = FeedManager::MAX_ITEMS / 2
  196. aggregate = account.user&.aggregates_reblogs?
  197. timeline_key = key(:home, account.id)
  198. account.statuses.limit(limit).each do |status|
  199. add_to_feed(:home, account.id, status, aggregate)
  200. end
  201. account.following.includes(:account_stat).find_each do |target_account|
  202. if redis.zcard(timeline_key) >= limit
  203. oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
  204. last_status_score = Mastodon::Snowflake.id_at(target_account.last_status_at)
  205. # If the feed is full and this account has not posted more recently
  206. # than the last item on the feed, then we can skip the whole account
  207. # because none of its statuses would stay on the feed anyway
  208. next if last_status_score < oldest_home_score
  209. end
  210. statuses = target_account.statuses.where(visibility: [:public, :unlisted, :private]).includes(:preloadable_poll, :media_attachments, reblog: :account).limit(limit)
  211. crutches = build_crutches(account.id, statuses)
  212. statuses.each do |status|
  213. next if filter_from_home?(status, account.id, crutches)
  214. add_to_feed(:home, account.id, status, aggregate)
  215. end
  216. trim(:home, account.id)
  217. end
  218. end
  219. # Completely clear multiple feeds at once
  220. # @param [Symbol] type
  221. # @param [Array<Integer>] ids
  222. # @return [void]
  223. def clean_feeds!(type, ids)
  224. reblogged_id_sets = {}
  225. redis.pipelined do
  226. ids.each do |feed_id|
  227. redis.del(key(type, feed_id))
  228. reblog_key = key(type, feed_id, 'reblogs')
  229. # We collect a future for this: we don't block while getting
  230. # it, but we can iterate over it later.
  231. reblogged_id_sets[feed_id] = redis.zrange(reblog_key, 0, -1)
  232. redis.del(reblog_key)
  233. end
  234. end
  235. # Remove all of the reblog tracking keys we just removed the
  236. # references to.
  237. redis.pipelined do
  238. reblogged_id_sets.each do |feed_id, future|
  239. future.value.each do |reblogged_id|
  240. reblog_set_key = key(type, feed_id, "reblogs:#{reblogged_id}")
  241. redis.del(reblog_set_key)
  242. end
  243. end
  244. end
  245. end
  246. private
  247. # Trim a feed to maximum size by removing older items
  248. # @param [Symbol] type
  249. # @param [Integer] timeline_id
  250. # @return [void]
  251. def trim(type, timeline_id)
  252. timeline_key = key(type, timeline_id)
  253. reblog_key = key(type, timeline_id, 'reblogs')
  254. # Remove any items past the MAX_ITEMS'th entry in our feed
  255. redis.zremrangebyrank(timeline_key, 0, -(FeedManager::MAX_ITEMS + 1))
  256. # Get the score of the REBLOG_FALLOFF'th item in our feed, and stop
  257. # tracking anything after it for deduplication purposes.
  258. falloff_rank = FeedManager::REBLOG_FALLOFF
  259. falloff_range = redis.zrevrange(timeline_key, falloff_rank, falloff_rank, with_scores: true)
  260. falloff_score = falloff_range&.first&.last&.to_i
  261. return if falloff_score.nil?
  262. # Get any reblogs we might have to clean up after.
  263. redis.zrangebyscore(reblog_key, 0, falloff_score).each do |reblogged_id|
  264. # Remove it from the set of reblogs we're tracking *first* to avoid races.
  265. redis.zrem(reblog_key, reblogged_id)
  266. # Just drop any set we might have created to track additional reblogs.
  267. # This means that if this reblog is deleted, we won't automatically insert
  268. # another reblog, but also that any new reblog can be inserted into the
  269. # feed.
  270. redis.del(key(type, timeline_id, "reblogs:#{reblogged_id}"))
  271. end
  272. end
  273. # Check if there is a streaming API client connected
  274. # for the given feed
  275. # @param [String] timeline_key
  276. # @return [Boolean]
  277. def push_update_required?(timeline_key)
  278. redis.exists?("subscribed:#{timeline_key}")
  279. end
  280. # Check if the account is blocking or muting any of the given accounts
  281. # @param [Integer] receiver_id
  282. # @param [Array<Integer>] account_ids
  283. # @param [Symbol] context
  284. def blocks_or_mutes?(receiver_id, account_ids, context)
  285. Block.where(account_id: receiver_id, target_account_id: account_ids).any? ||
  286. (context == :home ? Mute.where(account_id: receiver_id, target_account_id: account_ids).any? : Mute.where(account_id: receiver_id, target_account_id: account_ids, hide_notifications: true).any?)
  287. end
  288. # Check if status should not be added to the home feed
  289. # @param [Status] status
  290. # @param [Integer] receiver_id
  291. # @param [Hash] crutches
  292. # @return [Boolean]
  293. def filter_from_home?(status, receiver_id, crutches)
  294. return false if receiver_id == status.account_id
  295. return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
  296. check_for_blocks = crutches[:active_mentions][status.id] || []
  297. check_for_blocks.concat([status.account_id])
  298. if status.reblog?
  299. check_for_blocks.concat([status.reblog.account_id])
  300. check_for_blocks.concat(crutches[:active_mentions][status.reblog_of_id] || [])
  301. end
  302. return true if check_for_blocks.any? { |target_account_id| crutches[:blocking][target_account_id] || crutches[:muting][target_account_id] }
  303. if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
  304. should_filter = !crutches[:following][status.in_reply_to_account_id] # and I'm not following the person it's a reply to
  305. should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me
  306. should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply
  307. return !!should_filter
  308. elsif status.reblog? # Filter out a reblog
  309. should_filter = crutches[:hiding_reblogs][status.account_id] # if the reblogger's reblogs are suppressed
  310. should_filter ||= crutches[:blocked_by][status.reblog.account_id] # or if the author of the reblogged status is blocking me
  311. should_filter ||= crutches[:domain_blocking][status.reblog.account.domain] # or the author's domain is blocked
  312. return !!should_filter
  313. end
  314. false
  315. end
  316. # Check if status should not be added to the mentions feed
  317. # @see NotifyService
  318. # @param [Status] status
  319. # @param [Integer] receiver_id
  320. # @return [Boolean]
  321. def filter_from_mentions?(status, receiver_id)
  322. return true if receiver_id == status.account_id
  323. # This filter is called from NotifyService, but already after the sender of
  324. # the notification has been checked for mute/block. Therefore, it's not
  325. # necessary to check the author of the toot for mute/block again
  326. check_for_blocks = status.active_mentions.pluck(:account_id)
  327. check_for_blocks.concat([status.in_reply_to_account]) if status.reply? && !status.in_reply_to_account_id.nil?
  328. should_filter = blocks_or_mutes?(receiver_id, check_for_blocks, :mentions) # Filter if it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked (or muted)
  329. should_filter ||= (status.account.silenced? && !Follow.where(account_id: receiver_id, target_account_id: status.account_id).exists?) # of if the account is silenced and I'm not following them
  330. should_filter
  331. end
  332. # Check if status should not be added to the list feed
  333. # @param [Status] status
  334. # @param [List] list
  335. # @return [Boolean]
  336. def filter_from_list?(status, list)
  337. if status.reply? && status.in_reply_to_account_id != status.account_id
  338. should_filter = status.in_reply_to_account_id != list.account_id
  339. should_filter &&= !list.show_followed?
  340. should_filter &&= !(list.show_list? && ListAccount.where(list_id: list.id, account_id: status.in_reply_to_account_id).exists?)
  341. return !!should_filter
  342. end
  343. false
  344. end
  345. # Adds a status to an account's feed, returning true if a status was
  346. # added, and false if it was not added to the feed. Note that this is
  347. # an internal helper: callers must call trim or push updates if
  348. # either action is appropriate.
  349. # @param [Symbol] timeline_type
  350. # @param [Integer] account_id
  351. # @param [Status] status
  352. # @param [Boolean] aggregate_reblogs
  353. # @return [Boolean]
  354. def add_to_feed(timeline_type, account_id, status, aggregate_reblogs = true)
  355. timeline_key = key(timeline_type, account_id)
  356. reblog_key = key(timeline_type, account_id, 'reblogs')
  357. if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
  358. # If the original status or a reblog of it is within
  359. # REBLOG_FALLOFF statuses from the top, do not re-insert it into
  360. # the feed
  361. rank = redis.zrevrank(timeline_key, status.reblog_of_id)
  362. return false if !rank.nil? && rank < FeedManager::REBLOG_FALLOFF
  363. # The ordered set at `reblog_key` holds statuses which have a reblog
  364. # in the top `REBLOG_FALLOFF` statuses of the timeline
  365. if redis.zadd(reblog_key, status.id, status.reblog_of_id, nx: true)
  366. # This is not something we've already seen reblogged, so we
  367. # can just add it to the feed (and note that we're reblogging it).
  368. redis.zadd(timeline_key, status.id, status.id)
  369. else
  370. # Another reblog of the same status was already in the
  371. # REBLOG_FALLOFF most recent statuses, so we note that this
  372. # is an "extra" reblog, by storing it in reblog_set_key.
  373. reblog_set_key = key(timeline_type, account_id, "reblogs:#{status.reblog_of_id}")
  374. redis.sadd(reblog_set_key, status.id)
  375. return false
  376. end
  377. else
  378. # A reblog may reach earlier than the original status because of the
  379. # delay of the worker delivering the original status, the late addition
  380. # by merging timelines, and other reasons.
  381. # If such a reblog already exists, just do not re-insert it into the feed.
  382. return false unless redis.zscore(reblog_key, status.id).nil?
  383. redis.zadd(timeline_key, status.id, status.id)
  384. end
  385. true
  386. end
  387. # Removes an individual status from a feed, correctly handling cases
  388. # with reblogs, and returning true if a status was removed. As with
  389. # `add_to_feed`, this does not trigger push updates, so callers must
  390. # do so if appropriate.
  391. # @param [Symbol] timeline_type
  392. # @param [Integer] account_id
  393. # @param [Status] status
  394. # @param [Boolean] aggregate_reblogs
  395. # @return [Boolean]
  396. def remove_from_feed(timeline_type, account_id, status, aggregate_reblogs = true)
  397. timeline_key = key(timeline_type, account_id)
  398. reblog_key = key(timeline_type, account_id, 'reblogs')
  399. if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
  400. # 1. If the reblogging status is not in the feed, stop.
  401. status_rank = redis.zrevrank(timeline_key, status.id)
  402. return false if status_rank.nil?
  403. # 2. Remove reblog from set of this status's reblogs.
  404. reblog_set_key = key(timeline_type, account_id, "reblogs:#{status.reblog_of_id}")
  405. redis.srem(reblog_set_key, status.id)
  406. redis.zrem(reblog_key, status.reblog_of_id)
  407. # 3. Re-insert another reblog or original into the feed if one
  408. # remains in the set. We could pick a random element, but this
  409. # set should generally be small, and it seems ideal to show the
  410. # oldest potential such reblog.
  411. other_reblog = redis.smembers(reblog_set_key).map(&:to_i).min
  412. redis.zadd(timeline_key, other_reblog, other_reblog) if other_reblog
  413. redis.zadd(reblog_key, other_reblog, status.reblog_of_id) if other_reblog
  414. # 4. Remove the reblogging status from the feed (as normal)
  415. # (outside conditional)
  416. else
  417. # If the original is getting deleted, no use for reblog references
  418. redis.del(key(timeline_type, account_id, "reblogs:#{status.id}"))
  419. redis.zrem(reblog_key, status.id)
  420. end
  421. redis.zrem(timeline_key, status.id)
  422. end
  423. # Pre-fetch various objects and relationships for given statuses that
  424. # are going to be checked by the filtering methods
  425. # @param [Integer] receiver_id
  426. # @param [Array<Status>] statuses
  427. # @return [Hash]
  428. def build_crutches(receiver_id, statuses)
  429. crutches = {}
  430. crutches[:active_mentions] = Mention.active.where(status_id: statuses.flat_map { |s| [s.id, s.reblog_of_id] }.compact).pluck(:status_id, :account_id).each_with_object({}) { |(id, account_id), mapping| (mapping[id] ||= []).push(account_id) }
  431. check_for_blocks = statuses.flat_map do |s|
  432. arr = crutches[:active_mentions][s.id] || []
  433. arr.concat([s.account_id])
  434. if s.reblog?
  435. arr.concat([s.reblog.account_id])
  436. arr.concat(crutches[:active_mentions][s.reblog_of_id] || [])
  437. end
  438. arr
  439. end
  440. crutches[:following] = Follow.where(account_id: receiver_id, target_account_id: statuses.map(&:in_reply_to_account_id).compact).pluck(:target_account_id).index_with(true)
  441. crutches[:hiding_reblogs] = Follow.where(account_id: receiver_id, target_account_id: statuses.map { |s| s.account_id if s.reblog? }.compact, show_reblogs: false).pluck(:target_account_id).index_with(true)
  442. crutches[:blocking] = Block.where(account_id: receiver_id, target_account_id: check_for_blocks).pluck(:target_account_id).index_with(true)
  443. crutches[:muting] = Mute.where(account_id: receiver_id, target_account_id: check_for_blocks).pluck(:target_account_id).index_with(true)
  444. crutches[:domain_blocking] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.map { |s| s.reblog&.account&.domain }.compact).pluck(:domain).index_with(true)
  445. crutches[:blocked_by] = Block.where(target_account_id: receiver_id, account_id: statuses.map { |s| s.reblog&.account_id }.compact).pluck(:account_id).index_with(true)
  446. crutches
  447. end
  448. end