闭社主体 forked from https://github.com/tootsuite/mastodon
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.

36 lines
1.1 KiB

  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. deliver_to_public(status)
  9. end
  10. private
  11. def deliver_to_self(status)
  12. FeedManager.instance.push(:home, status.account, status)
  13. end
  14. def deliver_to_followers(status)
  15. status.account.followers.each do |follower|
  16. next if !follower.local? || FeedManager.instance.filter?(:home, status, follower)
  17. FeedManager.instance.push(:home, follower, status)
  18. end
  19. end
  20. def deliver_to_mentioned(status)
  21. status.mentions.each do |mention|
  22. mentioned_account = mention.account
  23. next if !mentioned_account.local? || mentioned_account.id == status.account_id || FeedManager.instance.filter?(:mentions, status, mentioned_account)
  24. FeedManager.instance.push(:mentions, mentioned_account, status)
  25. end
  26. end
  27. def deliver_to_public(status)
  28. return if status.account.silenced?
  29. FeedManager.instance.broadcast(:public, id: status.id)
  30. end
  31. end