about summary refs log tree commit diff
path: root/app/services/fan_out_on_write_service.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-10-22 18:15:51 +0200
committerThibaut Girka <thib@sitedethib.com>2018-10-22 18:15:51 +0200
commite45a6edd6574c86409333cc64f9fb87e1b0a196e (patch)
treee69ce0b67ebb7616854e90941a8fd086a530477e /app/services/fan_out_on_write_service.rb
parentdcded13a996e1b6b87444641eed66fc2d117e1af (diff)
Keep new DMs in home feeds and in the old DM timeline
Revert server-side part of 87fdd139b890e60f752bf71e3b09d79eaefcf7b5
Diffstat (limited to 'app/services/fan_out_on_write_service.rb')
-rw-r--r--app/services/fan_out_on_write_service.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 7f2a91775..0e9465d48 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -9,6 +9,8 @@ class FanOutOnWriteService < BaseService
     render_anonymous_payload(status)
 
     if status.direct_visibility?
+      deliver_to_mentioned_followers(status)
+      deliver_to_direct_timelines(status)
       deliver_to_own_conversation(status)
     elsif status.limited_visibility?
       deliver_to_mentioned_followers(status)
@@ -93,6 +95,16 @@ class FanOutOnWriteService < BaseService
     Redis.current.publish('timeline:public:local:media', @payload) if status.local?
   end
 
+  def deliver_to_direct_timelines(status)
+    Rails.logger.debug "Delivering status #{status.id} to direct timelines"
+
+    status.mentions.includes(:account).each do |mention|
+      Redis.current.publish("timeline:direct:#{mention.account.id}", @payload) if mention.account.local?
+    end
+
+    Redis.current.publish("timeline:direct:#{status.account.id}", @payload) if status.account.local?
+  end
+
   def deliver_to_own_conversation(status)
     AccountConversation.add_status(status.account, status)
   end