end
def block
- BlockService.new.call(current_user.account, @account)
- set_relationship
+ BlockWorker.perform_async(current_user.account_id, @account.id)
+
+ @following = { @account.id => false }
+ @followed_by = { @account.id => false }
+ @blocking = { @account.id => true }
+ @requested = { @account.id => false }
+
render action: :relationship
end
trim(:home, into_account.id)
end
+ def unmerge_from_timeline(from_account, into_account)
+ timeline_key = key(:home, into_account.id)
+
+ from_account.statuses.select('id').find_each do |status|
+ redis.zrem(timeline_key, status.id)
+ redis.zremrangebyscore(timeline_key, status.id, status.id)
+ end
+ end
+
def inline_render(target_account, template, object)
rabl_scope = Class.new do
include RoutingHelper
NotificationWorker.perform_async(follow.stream_entry.id, target_account.id)
end
- FeedManager.instance.merge_into_timeline(target_account, source_account)
+ MergeWorker.perform_async(target_account.id, source_account.id)
Pubsubhubbub::DistributionWorker.perform_async(follow.stream_entry.id)
follow
def call(source_account, target_account)
follow = source_account.unfollow!(target_account)
NotificationWorker.perform_async(follow.stream_entry.id, target_account.id) unless target_account.local?
- unmerge_from_timeline(target_account, source_account)
- end
-
- private
-
- def unmerge_from_timeline(from_account, into_account)
- timeline_key = FeedManager.instance.key(:home, into_account.id)
-
- from_account.statuses.select('id').find_each do |status|
- redis.zrem(timeline_key, status.id)
- redis.zremrangebyscore(timeline_key, status.id, status.id)
- end
- end
-
- def redis
- Redis.current
+ UnmergeWorker.perform_async(target_account.id, source_account.id)
end
end
--- /dev/null
+# frozen_string_literal: true
+
+class BlockWorker
+ include Sidekiq::Worker
+
+ def perform(account_id, target_account_id)
+ BlockService.new.call(Account.find(account_id), Account.find(target_account_id))
+ end
+end
--- /dev/null
+# frozen_string_literal: true
+
+class MergeWorker
+ include Sidekiq::Worker
+
+ def perform(from_account_id, into_account_id)
+ FeedManager.instance.merge_into_timeline(Account.find(from_account_id), Account.find(into_account_id))
+ end
+end
--- /dev/null
+# frozen_string_literal: true
+
+class UnmergeWorker
+ include Sidekiq::Worker
+
+ def perform(from_account_id, into_account_id)
+ FeedManager.instance.unmerge_from_timeline(Account.find(from_account_id), Account.find(into_account_id))
+ end
+end