about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-03-01 01:07:11 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-03-01 01:07:11 +0100
commit7f0d1b8cc0ddf11de82de1850d53883a8da434cc (patch)
tree8e6cdb7e76f364e831e057371054d41e8822463c
parent92569b1f0d2a1e4a5b131ce560766b023a71ccb1 (diff)
If a status is within 40 statuses from the top of a home feed, do not
reinsert it when someone boosts it
-rw-r--r--app/lib/feed_manager.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 623a1af03..016ef0235 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -22,8 +22,18 @@ class FeedManager
   end
 
   def push(timeline_type, account, status)
-    redis.zadd(key(timeline_type, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
-    trim(timeline_type, account.id)
+    timeline_key = key(timeline_type, account.id)
+
+    if status.reblog?
+      # If the original status is within 40 statuses from top, do not re-insert it into the feed
+      rank = redis.zrevrank(timeline_key, status.reblog_of_id)
+      return if !rank.nil? && rank < 40
+      redis.zadd(timeline_key, status.id, status.reblog_of_id)
+    else
+      redis.zadd(timeline_key, status.id, status.id)
+      trim(timeline_type, account.id)
+    end
+
     broadcast(account.id, event: 'update', payload: inline_render(account, 'api/v1/statuses/show', status))
   end