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 17:51:38 +0200
committerThibaut Girka <thib@sitedethib.com>2018-10-22 17:51:38 +0200
commitdcded13a996e1b6b87444641eed66fc2d117e1af (patch)
tree1be2c25853e7196a38b0bebc13e9f5281a24d908 /app/services/fan_out_on_write_service.rb
parent4739e0f090a04235669ef81fa432ae90bb62f4c4 (diff)
parent4f0bdbaaaf6828d7ee6fd6e6023375b727c0afe5 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- .github/ISSUE_TEMPLATE/bug_report.md
  Took our version.
- CONTRIBUTING.md
  Updated the embedded copy of upstream's version.
- README.md
  Took our version.
- app/policies/status_policy.rb
  Not a real conflict, took code from both.
- app/views/layouts/embedded.html.haml
  Added upstream's changes (dns-prefetch) and fixed
  `%body.embed`
- app/views/settings/preferences/show.html.haml
  Reverted some of upstream changes, as we have a
  page dedicated for flavours and skins.
- config/initializers/content_security_policy.rb
  Kept our version of the CSP.
- config/initializers/doorkeeper.rb
  Not a real conflict, took code from both.
Diffstat (limited to 'app/services/fan_out_on_write_service.rb')
-rw-r--r--app/services/fan_out_on_write_service.rb19
1 files changed, 4 insertions, 15 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index ab520276b..7f2a91775 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -6,15 +6,14 @@ class FanOutOnWriteService < BaseService
   def call(status)
     raise Mastodon::RaceConditionError if status.visibility.nil?
 
-    deliver_to_self(status) if status.account.local?
-
     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)
     else
+      deliver_to_self(status) if status.account.local?
       deliver_to_followers(status)
       deliver_to_lists(status)
     end
@@ -57,7 +56,7 @@ class FanOutOnWriteService < BaseService
   end
 
   def deliver_to_mentioned_followers(status)
-    Rails.logger.debug "Delivering status #{status.id} to mentioned followers"
+    Rails.logger.debug "Delivering status #{status.id} to limited followers"
 
     status.mentions.includes(:account).each do |mention|
       mentioned_account = mention.account
@@ -94,16 +93,6 @@ 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