diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-08-08 09:59:14 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-08-08 12:46:17 -0500 |
commit | 4dfc40324b1f3b20550982621501e162d2ed3bed (patch) | |
tree | 1578cba8809b7db27dc82f4d439471194d5fad31 /app/lib/activitypub/activity | |
parent | d019e55b7bc496d3c4d942fb4ffe65bb7e149249 (diff) |
add new `reject unknown` policy option to prevent spam & harassment from large/undermoderated servers
Diffstat (limited to 'app/lib/activitypub/activity')
-rw-r--r-- | app/lib/activitypub/activity/announce.rb | 2 | ||||
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 8 | ||||
-rw-r--r-- | app/lib/activitypub/activity/follow.rb | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/app/lib/activitypub/activity/announce.rb b/app/lib/activitypub/activity/announce.rb index ada46b378..245126123 100644 --- a/app/lib/activitypub/activity/announce.rb +++ b/app/lib/activitypub/activity/announce.rb @@ -5,7 +5,7 @@ class ActivityPub::Activity::Announce < ActivityPub::Activity return if autoreject? return reject_payload! if !@options[:imported] && (delete_arrived_first?(@json['id']) || !related_to_local_activity?) - original_status = status_from_object + original_status = status_from_object(announced_by: @account) return reject_payload! if original_status.nil? || !announceable?(original_status) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 140226481..37aac4d59 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -5,6 +5,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return if autoreject? return reject_payload! if unsupported_object_type? || !@options[:imported] && (invalid_origin?(@object['id']) || Tombstone.exists?(uri: @object['id']) || !related_to_local_activity?) + unless known? + if @options[:announced_by].nil? + return reject_payload! if !@options[:requested] && rejecting_unknown? + else + @account.mark_known! if known?(@options[:announced_by]) + end + end + RedisLock.acquire(lock_options) do |lock| if lock.acquired? return if !@options[:imported] && (delete_arrived_first?(object_uri) || poll_vote?) diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index 84041ec8d..bde507dcf 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -7,7 +7,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id']) || @account.requested?(target_account) - if target_account.blocking?(@account) || target_account.domain_blocking?(@account.domain) || target_account.moved? + if (rejecting_unknown? && !known?) || target_account.blocking?(@account) || target_account.domain_blocking?(@account.domain) || target_account.moved? reject_follow_request!(target_account) return end |