diff options
author | Starfall <us@starfall.systems> | 2020-12-07 09:35:37 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-12-07 09:35:37 -0600 |
commit | 0f6d41052652c4fee87a19900795c8588d9a2174 (patch) | |
tree | a9440e6aa871459b4892eddcf5a72ae8d53990ba /app/lib | |
parent | d085d49922b2ae32201caf5751344f5d88ccae4b (diff) | |
parent | 25f725d67a6d2542cd586ab7c56baca572eb4f88 (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/status_reach_finder.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/app/lib/status_reach_finder.rb b/app/lib/status_reach_finder.rb new file mode 100644 index 000000000..35b191dad --- /dev/null +++ b/app/lib/status_reach_finder.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +class StatusReachFinder + def initialize(status) + @status = status + end + + def inboxes + Account.where(id: reached_account_ids).inboxes + end + + private + + def reached_account_ids + [ + replied_to_account_id, + reblog_of_account_id, + mentioned_account_ids, + reblogs_account_ids, + favourites_account_ids, + replies_account_ids, + ].tap do |arr| + arr.flatten! + arr.compact! + arr.uniq! + end + end + + def replied_to_account_id + @status.in_reply_to_account_id + end + + def reblog_of_account_id + @status.reblog.account_id if @status.reblog? + end + + def mentioned_account_ids + @status.mentions.pluck(:account_id) + end + + def reblogs_account_ids + @status.reblogs.pluck(:account_id) + end + + def favourites_account_ids + @status.favourites.pluck(:account_id) + end + + def replies_account_ids + @status.replies.pluck(:account_id) + end +end |