about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorClworld <clworld@ggtea.org>2017-06-04 03:50:53 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-03 20:50:53 +0200
commitdab8fc458420b5773a47ba232aabe089d0ff45b5 (patch)
tree061d20ffaea7355c52c0a90a607c95e2eaa13cf9 /app
parent8a597f01388b8dd0ab1805233b18233d8606061a (diff)
Execute PushUpdateWorker only for accounts who uses StreamingAPI just now. (#3278)
* Add redis key "subscribed:timeline:#{account.id}" to indicate active streaming API listeners exists.

* Add endpoint for notification only stream.

* Run PushUpdateWorker only for users uses Streaming API now.

* Move close hander streamTo(Http/Ws) -> stream(Http/Ws)End (Deal with #3370)

* Add stream type for stream start log message.
Diffstat (limited to 'app')
-rw-r--r--app/lib/feed_manager.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index c2d3a2e2c..86928fa36 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -34,7 +34,7 @@ class FeedManager
       trim(timeline_type, account.id)
     end
 
-    PushUpdateWorker.perform_async(account.id, status.id)
+    PushUpdateWorker.perform_async(account.id, status.id) if push_update_required?(timeline_type, account.id)
   end
 
   def trim(type, account_id)
@@ -43,6 +43,10 @@ class FeedManager
     redis.zremrangebyscore(key(type, account_id), '-inf', "(#{last.last}")
   end
 
+  def push_update_required?(timeline_type, account_id)
+    timeline_type != :home || redis.get("subscribed:timeline:#{account_id}").present?
+  end
+
   def merge_into_timeline(from_account, into_account)
     timeline_key = key(:home, into_account.id)
     query        = from_account.statuses.limit(FeedManager::MAX_ITEMS / 4)