diff options
Diffstat (limited to 'app/services/block_service.rb')
-rw-r--r-- | app/services/block_service.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/services/block_service.rb b/app/services/block_service.rb new file mode 100644 index 000000000..6c841d25b --- /dev/null +++ b/app/services/block_service.rb @@ -0,0 +1,25 @@ +class BlockService < BaseService + def call(account, target_account) + return if account.id == target_account.id + + UnfollowService.new.call(account, target_account) if account.following?(target_account) + account.block!(target_account) + clear_mentions(account, target_account) + end + + private + + def clear_mentions(account, target_account) + timeline_key = FeedManager.instance.key(:mentions, account.id) + + target_account.statuses.select('id').find_each do |status| + redis.zrem(timeline_key, status.id) + end + + FeedManager.instance.broadcast(account.id, type: 'block', id: target_account.id) + end + + def redis + $redis + end +end |