about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-01 15:58:53 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:16 -0500
commitf17bab4a35cfc168f2c2d7a22bebdfa1e8c72876 (patch)
treec1f9cbc02f2ddee74816f2b1b05f1d92326c0b31
parentf621f3d1e8336c14ed9a5dfe1e1030634732a41e (diff)
[Federation] cc implicit participants of limited-audience messages
-rw-r--r--app/lib/activitypub/tag_manager.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb
index 7951c130a..c26301f7e 100644
--- a/app/lib/activitypub/tag_manager.rb
+++ b/app/lib/activitypub/tag_manager.rb
@@ -104,6 +104,24 @@ class ActivityPub::TagManager
       cc << account_followers_url(status.account)
     when 'unlisted'
       cc << COLLECTIONS[:public]
+    when 'limited'
+      if status.account.silenced?
+        # Only notify followers if the account is locally silenced
+        account_ids = status.silent_mentions.pluck(:account_id)
+        cc.concat(status.account.followers.where(id: account_ids).each_with_object([]) do |account, result|
+          result << uri_for(account)
+          result << account_followers_url(account) if account.group?
+        end)
+        cc.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).each_with_object([]) do |request, result|
+          result << uri_for(request.account)
+          result << account_followers_url(request.account) if request.account.group?
+        end)
+      else
+        cc.concat(status.silent_mentions.each_with_object([]) do |mention, result|
+          result << uri_for(mention.account)
+          result << account_followers_url(mention.account) if mention.account.group?
+        end)
+      end
     end
 
     unless %w(direct limited).include?(visibility)