about summary refs log tree commit diff
path: root/app/services/unfollow_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-10 18:36:48 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-10 18:36:48 +0200
commit0077fc26df2982720e5fb278af6540a47859386f (patch)
treec7de413748f9a235779cd354f06d291f84498183 /app/services/unfollow_service.rb
parent35b6c4b36aa483e9936315cb72c2cf1fd2f477f6 (diff)
Merge and unmerge timelines on follow/unfollow, solves #21, #22
Diffstat (limited to 'app/services/unfollow_service.rb')
-rw-r--r--app/services/unfollow_service.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb
index 92d86a2c5..4d9c2a9a7 100644
--- a/app/services/unfollow_service.rb
+++ b/app/services/unfollow_service.rb
@@ -5,5 +5,20 @@ class UnfollowService < BaseService
   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.find_each do |status|
+      redis.zrem(timeline_key, status.id)
+    end
+  end
+
+  def redis
+    $redis
   end
 end