diff options
author | ThibG <thib@sitedethib.com> | 2019-05-09 22:05:43 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2019-05-09 22:05:43 +0200 |
commit | 62f5235b6f906a3336292a1a3afa222084de9a97 (patch) | |
tree | 20ddb66eaa86ed505d7871c59536c3da51f8e56b /app/lib/activitypub | |
parent | 26fc21c18844802652ff1f5910acaa91ebe19de4 (diff) |
Prevent silenced local users from notifying remote users not following them (#10575)
* Prevent silenced local users from notifying remote users not following them This is an attempt to extend the local restrictions of silenced users to the federation. * Add tests * Add tests for making sure private status don't get sent over OStatus
Diffstat (limited to 'app/lib/activitypub')
-rw-r--r-- | app/lib/activitypub/tag_manager.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 892bb9974..595291342 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -65,7 +65,14 @@ class ActivityPub::TagManager when 'unlisted', 'private' [account_followers_url(status.account)] when 'direct', 'limited' - status.active_mentions.map { |mention| uri_for(mention.account) } + if status.account.silenced? + # Only notify followers if the account is locally silenced + account_ids = status.active_mentions.pluck(:account_id) + to = status.account.followers.where(id: account_ids).map { |account| uri_for(account) } + to.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).map { |request| uri_for(request.account) }) + else + status.active_mentions.map { |mention| uri_for(mention.account) } + end end end @@ -86,7 +93,16 @@ class ActivityPub::TagManager cc << COLLECTIONS[:public] end - cc.concat(status.active_mentions.map { |mention| uri_for(mention.account) }) unless status.direct_visibility? || status.limited_visibility? + unless status.direct_visibility? || status.limited_visibility? + if status.account.silenced? + # Only notify followers if the account is locally silenced + account_ids = status.active_mentions.pluck(:account_id) + cc.concat(status.account.followers.where(id: account_ids).map { |account| uri_for(account) }) + cc.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).map { |request| uri_for(request.account) }) + else + cc.concat(status.active_mentions.map { |mention| uri_for(mention.account) }) + end + end cc end |