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.

25 lines
658 B

  1. class BlockService < BaseService
  2. def call(account, target_account)
  3. return if account.id == target_account.id
  4. UnfollowService.new.call(account, target_account) if account.following?(target_account)
  5. account.block!(target_account)
  6. clear_mentions(account, target_account)
  7. end
  8. private
  9. def clear_mentions(account, target_account)
  10. timeline_key = FeedManager.instance.key(:mentions, account.id)
  11. target_account.statuses.select('id').find_each do |status|
  12. redis.zrem(timeline_key, status.id)
  13. end
  14. FeedManager.instance.broadcast(account.id, type: 'block', id: target_account.id)
  15. end
  16. def redis
  17. $redis
  18. end
  19. end