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.

30 lines
970 B

  1. class FanOutOnWriteService < BaseService
  2. # Push a status into home and mentions feeds
  3. # @param [Status] status
  4. def call(status)
  5. deliver_to_self(status) if status.account.local?
  6. deliver_to_followers(status)
  7. deliver_to_mentioned(status)
  8. end
  9. private
  10. def deliver_to_self(status)
  11. FeedManager.instance.push(:home, status.account, status)
  12. end
  13. def deliver_to_followers(status)
  14. status.account.followers.each do |follower|
  15. next if !follower.local? || FeedManager.instance.filter?(:home, status, follower)
  16. FeedManager.instance.push(:home, follower, status)
  17. end
  18. end
  19. def deliver_to_mentioned(status)
  20. status.mentions.each do |mention|
  21. mentioned_account = mention.account
  22. next if !mentioned_account.local? || mentioned_account.id == status.account_id || FeedManager.instance.filter?(:mentions, status, mentioned_account)
  23. FeedManager.instance.push(:mentions, mentioned_account, status)
  24. end
  25. end
  26. end