about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-04-14 15:22:55 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:21 -0500
commit2db51e2f4cc55c520634df8ca34b58742ded0153 (patch)
tree8236f6a359d6d501228cf60c725289c252445e27 /app/services
parentc86c4b95bee3a51ea7a0d11f0a26b50202853dde (diff)
Refactored community-curated world timeline code; **privacy**: remove support for packmate-visible hashtags until we resolve federation caveats.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fan_out_on_write_service.rb23
-rw-r--r--app/services/favourite_service.rb11
-rw-r--r--app/services/reblog_service.rb8
3 files changed, 25 insertions, 17 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index a81482dd6..0dd1ec7ec 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -3,7 +3,7 @@
 class FanOutOnWriteService < BaseService
   # Push a status into home and mentions feeds
   # @param [Status] status
-  def call(status, allow_nonlocal = false, deliver_to_local = true)
+  def call(status)
     raise Mastodon::RaceConditionError if status.visibility.nil?
 
     deliver_to_self(status) if status.account.local?
@@ -24,25 +24,21 @@ class FanOutOnWriteService < BaseService
     return if status.reblog? && !Setting.show_reblogs_in_public_timelines
     return if status.account.silenced?
 
-    deliver_to_hashtags(status) if !status.reblog? && status.distributable?
-
-    # we want to let community users decide what goes on the ftl with boosts
-    return unless allow_nonlocal || status.network? || status.relayed?
+    if !status.reblog? && status.distributable?
+      deliver_to_hashtags(status)
+      deliver_to_public(status) if status.curated
+    end
 
-    if status.reblog? then
+    if status.relayed?
       status = Status.find(status.reblog_of_id)
+      return if status.account.silenced?
       render_anonymous_payload(status)
-      deliver_to_local = status.network?
     end
 
-    return if status.account.silenced? || !status.public_visibility?
+    return unless status.network? && status.public_visibility? && !status.reblog
     return if status.reply? && status.in_reply_to_account_id != status.account_id && !Setting.show_replies_in_public_timelines
 
-    if deliver_to_local then
-      deliver_to_local(status)
-    else
-      deliver_to_public(status)
-    end
+    deliver_to_local(status)
   end
 
   private
@@ -104,7 +100,6 @@ class FanOutOnWriteService < BaseService
   def deliver_to_local(status)
     Rails.logger.debug "Delivering status #{status.id} to local timeline"
 
-    return unless status.network?
     Redis.current.publish('timeline:public:local', @payload)
     Redis.current.publish('timeline:public:local:media', @payload) if status.media_attachments.any?
   end
diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb
index fd7ade02b..42e137564 100644
--- a/app/services/favourite_service.rb
+++ b/app/services/favourite_service.rb
@@ -16,9 +16,7 @@ class FavouriteService < BaseService
 
     favourite = Favourite.create!(account: account, status: status)
 
-    # stream it to the world timeline if public
-    FanOutOnWriteService.new.call(status, true, false) if status.public_visibility?
-
+    curate_status(status)
     create_notification(favourite)
     bump_potential_friendship(account, status)
 
@@ -56,4 +54,11 @@ class FavouriteService < BaseService
   def build_xml(favourite)
     OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.favourite_salmon(favourite))
   end
+
+  def curate_status(status)
+    return if status.curated
+    status.curated = true
+    status.save
+    FanOutOnWriteService.new.call(status)
+  end
 end
diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb
index 77ec52ab8..049e915df 100644
--- a/app/services/reblog_service.rb
+++ b/app/services/reblog_service.rb
@@ -29,6 +29,7 @@ class ReblogService < BaseService
       ActivityPub::DistributionWorker.perform_async(reblog.id)
     end
 
+    curate_status(reblogged_status)
     create_notification(reblog)
     bump_potential_friendship(account, reblog)
 
@@ -62,4 +63,11 @@ class ReblogService < BaseService
       adapter: ActivityPub::Adapter
     ).as_json).sign!(reblog.account))
   end
+
+  def curate_status(status)
+    return if status.curated
+    status.curated = true
+    status.save
+    FanOutOnWriteService.new.call(status)
+  end
 end