about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-11-02 10:50:13 -0600
committerFire Demon <firedemon@creature.cafe>2020-11-02 14:03:18 -0600
commitff1125404eec13cdc8aab7e99f76767428794a89 (patch)
tree0de2783f2b73876d4055bc0288121f2bb8b7ae6b
parent2f230d5c60dcb003b2bad8213daa26a27c6f8610 (diff)
Address instance actor to work around Mastodon visibility heuristic bug
-rw-r--r--app/lib/activitypub/tag_manager.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb
index 4b729459f..fb1c9d7b2 100644
--- a/app/lib/activitypub/tag_manager.rb
+++ b/app/lib/activitypub/tag_manager.rb
@@ -65,15 +65,15 @@ class ActivityPub::TagManager
   # Unlisted and private statuses go out primarily to the followers collection
   # Others go out only to the people they mention
   def to(status, target_domain: nil)
-    case status.visibility_for_domain(target_domain)
+    visibility = status.visibility_for_domain(target_domain)
+    case visibility
     when 'public', 'unlisted'
       [status.tags.present? ? COLLECTIONS[:public] : account_followers_url(status.account)]
     else
       account_ids = status.active_mentions.pluck(:account_id)
-      account_ids |= status.account.follower_ids if status.private_visibility?
+      account_ids |= status.account.follower_ids if visibility == 'private'
 
       accounts = status.account.silenced? ? status.account.followers.where(id: account_ids) : Account.where(id: account_ids)
-      accounts = accounts.remote.activitypub
       accounts = accounts.where(domain: target_domain) if target_domain.present?
 
       accounts.each_with_object([]) do |account, result|
@@ -99,6 +99,8 @@ class ActivityPub::TagManager
       cc << (status.tags.present? ? account_followers_url(status.account) : COLLECTIONS[:public])
       account_ids = status.active_mentions.pluck(:account_id)
     when 'private', 'limited'
+      # Work around Mastodon visibility heuritic bug by addressing instance actor.
+      cc << instance_actor_url
       account_ids = status.silent_mentions.pluck(:account_id)
     else
       account_ids = []
@@ -106,7 +108,6 @@ class ActivityPub::TagManager
 
     if account_ids.present?
       accounts = status.account.silenced? ? status.account.followers.where(id: account_ids) : Account.where(id: account_ids)
-      accounts = accounts.remote.activitypub
       accounts = accounts.where(domain: target_domain) if target_domain.present?
 
       cc.concat(accounts.each_with_object([]) do |account, result|