]> cat aescling's git repositories - mastodon.git/commitdiff
If a status is within 40 statuses from the top of a home feed, do not
authorEugen Rochko <eugen@zeonfederated.com>
Wed, 1 Mar 2017 00:07:11 +0000 (01:07 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 1 Mar 2017 00:07:11 +0000 (01:07 +0100)
reinsert it when someone boosts it

app/lib/feed_manager.rb

index 623a1af035225a0a62afc5523268f9f51741b786..016ef02356e731feb467265dca73f2d46f1d0431 100644 (file)
@@ -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