diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-08-20 06:12:37 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:19 -0500 |
commit | a1d1ee39f79c5bd836dffa676c938c1d2c5e79ec (patch) | |
tree | fa1f5ea5f5d1ffcde4112c0b2228a899c0adf888 /app | |
parent | 00d24f263fe54e5f7ccf785666254232ebb07085 (diff) |
[Privacy] Choose random local follower for private fetches instead of first
Diffstat (limited to 'app')
-rw-r--r-- | app/lib/activitypub/activity.rb | 2 | ||||
-rw-r--r-- | app/models/account.rb | 1 | ||||
-rw-r--r-- | app/services/activitypub/fetch_featured_collection_service.rb | 2 | ||||
-rw-r--r-- | app/workers/thread_resolve_worker.rb | 2 |
4 files changed, 4 insertions, 3 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 9b58fabed..8a05e22cc 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -182,7 +182,7 @@ class ActivityPub::Activity end def first_local_follower - @account.followers.local.first + @account.followers.local.random.first end def follow_request_from_object diff --git a/app/models/account.rb b/app/models/account.rb index dab091bae..aad6dc728 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -120,6 +120,7 @@ class Account < ApplicationRecord scope :by_domain_and_subdomains, ->(domain) { where(domain: domain).or(where(arel_table[:domain].matches('%.' + domain))) } scope :not_excluded_by_account, ->(account) { where.not(id: account.excluded_from_timeline_account_ids) } scope :not_domain_blocked_by_account, ->(account) { where(arel_table[:domain].eq(nil).or(arel_table[:domain].not_in(account.excluded_from_timeline_domains))) } + scope :random, -> { reorder(Arel.sql('RANDOM()')).limit(1) } delegate :email, :unconfirmed_email, diff --git a/app/services/activitypub/fetch_featured_collection_service.rb b/app/services/activitypub/fetch_featured_collection_service.rb index c8006afce..a77c03bed 100644 --- a/app/services/activitypub/fetch_featured_collection_service.rb +++ b/app/services/activitypub/fetch_featured_collection_service.rb @@ -22,7 +22,7 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService private def process_items(items) - first_local_follower = @account.followers.local.first + first_local_follower = @account.followers.local.random.first status_ids = items.map { |item| value_or_id(item) } .reject { |uri| ActivityPub::TagManager.instance.local_uri?(uri) } .map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri, on_behalf_of: first_local_follower) } diff --git a/app/workers/thread_resolve_worker.rb b/app/workers/thread_resolve_worker.rb index e362b5b2b..7599eb784 100644 --- a/app/workers/thread_resolve_worker.rb +++ b/app/workers/thread_resolve_worker.rb @@ -8,7 +8,7 @@ class ThreadResolveWorker def perform(child_status_id, parent_url, on_behalf_of = nil) child_status = Status.find(child_status_id) - on_behalf_of = child_status.account.followers.local.first if on_behalf_of.nil? && !child_status.distributable? + on_behalf_of = child_status.account.followers.local.random.first if on_behalf_of.nil? && !child_status.distributable? parent_status = FetchRemoteStatusService.new.call(parent_url, nil, on_behalf_of) return if parent_status.nil? |