Skip to content

Commit

Permalink
Revert "merge upstream (bump version to 3.2.1) (#242)" (#243)
Browse files Browse the repository at this point in the history
This reverts commit 70fdfc0.
mashirozx authored Oct 26, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 70fdfc0 commit be70c76
Showing 28 changed files with 517 additions and 995 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ plugins:
channel: eslint-7
rubocop:
enabled: true
channel: rubocop-0-92
channel: rubocop-0-88
sass-lint:
enabled: true
exclude_patterns:
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ group :test do
end

group :development do
gem 'active_record_query_trace', '~> 1.8'
gem 'active_record_query_trace', '~> 1.7'
gem 'annotate', '~> 3.1'
gem 'better_errors', '~> 2.8'
gem 'binding_of_caller', '~> 0.7'
@@ -164,5 +164,3 @@ gem 'concurrent-ruby', require: false
gem 'connection_pool', require: false

gem "sidekiq-statistic", "~> 1.4"
gem 'xorcist', '~> 1.1'
gem 'pluck_each', '~> 0.1.3'
10 changes: 2 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ GEM
activemodel (>= 4.1, < 6.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
active_record_query_trace (1.8)
active_record_query_trace (1.7)
activejob (5.2.4.4)
activesupport (= 5.2.4.4)
globalid (>= 0.3.6)
@@ -407,9 +407,6 @@ GEM
pghero (2.7.2)
activerecord (>= 5)
pkg-config (1.4.4)
pluck_each (0.1.3)
activerecord (> 3.2.0)
activesupport (> 3.0.0)
posix-spawn (0.3.15)
premailer (1.14.2)
addressable
@@ -673,7 +670,6 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
wisper (2.0.1)
xorcist (1.1.2)
xpath (3.2.0)
nokogiri (~> 1.8)

@@ -682,7 +678,7 @@ PLATFORMS

DEPENDENCIES
active_model_serializers (~> 0.10)
active_record_query_trace (~> 1.8)
active_record_query_trace (~> 1.7)
addressable (~> 2.7)
annotate (~> 3.1)
aws-sdk-s3 (~> 1.83)
@@ -762,7 +758,6 @@ DEPENDENCIES
pg (~> 1.2)
pghero (~> 2.7)
pkg-config (~> 1.4)
pluck_each (~> 0.1.3)
posix-spawn
premailer-rails
private_address_check (~> 0.5)
@@ -813,7 +808,6 @@ DEPENDENCIES
webmock (~> 3.9)
webpacker (~> 5.2)
webpush
xorcist (~> 1.1)

RUBY VERSION
ruby 2.6.6p146

This file was deleted.

14 changes: 0 additions & 14 deletions app/controllers/activitypub/inboxes_controller.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ class ActivityPub::InboxesController < ActivityPub::BaseController

def create
upgrade_account
process_collection_synchronization
process_payload
head 202
end
@@ -53,19 +52,6 @@ def upgrade_account
DeliveryFailureTracker.reset!(signed_request_account.inbox_url)
end

def process_collection_synchronization
raw_params = request.headers['Collection-Synchronization']
return if raw_params.blank? || ENV['DISABLE_FOLLOWERS_SYNCHRONIZATION'] == 'true'

# Re-using the syntax for signature parameters
tree = SignatureParamsParser.new.parse(raw_params)
params = SignatureParamsTransformer.new.apply(tree)

ActivityPub::PrepareFollowersSynchronizationService.new.call(signed_request_account, params)
rescue Parslet::ParseFailed
Rails.logger.warn 'Error parsing Collection-Synchronization header'
end

def process_payload
ActivityPub::ProcessingWorker.perform_async(signed_request_account.id, body, @account&.id)
end
4 changes: 0 additions & 4 deletions app/lib/activitypub/tag_manager.rb
Original file line number Diff line number Diff line change
@@ -40,10 +40,6 @@ def uri_for(target)
end
end

def uri_for_username(username)
account_url(username: username)
end

def generate_uri_for(_target)
URI.join(root_url, 'payloads', SecureRandom.uuid)
end
1 change: 0 additions & 1 deletion app/lib/sanitize_config.rb
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ module Config
gopher
xmpp
magnet
gemini
).freeze

CLASS_WHITELIST_TRANSFORMER = lambda do |env|
2 changes: 2 additions & 0 deletions app/lib/settings/scoped_settings.rb
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ def initialize(object)
@object = object
end

# rubocop:disable Style/MethodMissingSuper
def method_missing(method, *args)
method_name = method.to_s
# set a value for a variable
@@ -23,6 +24,7 @@ def method_missing(method, *args)
self[method_name]
end
end
# rubocop:enable Style/MethodMissingSuper

def respond_to_missing?(*)
true
6 changes: 0 additions & 6 deletions app/models/account.rb
Original file line number Diff line number Diff line change
@@ -352,12 +352,6 @@ def preferred_inbox_url
shared_inbox_url.presence || inbox_url
end

def synchronization_uri_prefix
return 'local' if local?

@synchronization_uri_prefix ||= uri[/http(s?):\/\/[^\/]+\//]
end

class Field < ActiveModelSerializers::Model
attributes :name, :value, :verified_at, :account, :errors

20 changes: 0 additions & 20 deletions app/models/concerns/account_interactions.rb
Original file line number Diff line number Diff line change
@@ -243,26 +243,6 @@ def lists_for_local_distribution
.where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
end

def remote_followers_hash(url_prefix)
Rails.cache.fetch("followers_hash:#{id}:#{url_prefix}") do
digest = "\x00" * 32
followers.where(Account.arel_table[:uri].matches(url_prefix + '%', false, true)).pluck_each(:uri) do |uri|
Xorcist.xor!(digest, Digest::SHA256.digest(uri))
end
digest.unpack('H*')[0]
end
end

def local_followers_hash
Rails.cache.fetch("followers_hash:#{id}:local") do
digest = "\x00" * 32
followers.where(domain: nil).pluck_each(:username) do |username|
Xorcist.xor!(digest, Digest::SHA256.digest(ActivityPub::TagManager.instance.uri_for_username(username)))
end
digest.unpack('H*')[0]
end
end

private

def remove_potential_friendship(other_account, mutual = false)
8 changes: 0 additions & 8 deletions app/models/follow.rb
Original file line number Diff line number Diff line change
@@ -41,10 +41,8 @@ def revoke_request!

before_validation :set_uri, only: :create
after_create :increment_cache_counters
after_create :invalidate_hash_cache
after_destroy :remove_endorsements
after_destroy :decrement_cache_counters
after_destroy :invalidate_hash_cache

private

@@ -65,10 +63,4 @@ def decrement_cache_counters
account&.decrement_count!(:following_count)
target_account&.decrement_count!(:followers_count)
end

def invalidate_hash_cache
return if account.local? && target_account.local?

Rails.cache.delete("followers_hash:#{target_account_id}:#{account.synchronization_uri_prefix}")
end
end

This file was deleted.

2 changes: 1 addition & 1 deletion app/services/activitypub/process_account_service.rb
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ def collection_info(type)
total_items = collection.is_a?(Hash) && collection['totalItems'].present? && collection['totalItems'].is_a?(Numeric) ? collection['totalItems'] : nil
has_first_page = collection.is_a?(Hash) && collection['first'].present?
@collections[type] = [total_items, has_first_page]
rescue HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::LengthValidationError
rescue HTTP::Error, OpenSSL::SSL::SSLError
@collections[type] = [nil, nil]
end

74 changes: 0 additions & 74 deletions app/services/activitypub/synchronize_followers_service.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/services/process_mentions_service.rb
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ def create_notification(mention)
if mentioned_account.local?
LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name, :mention)
elsif mentioned_account.activitypub? && !@status.local_only?
ActivityPub::DeliveryWorker.perform_async(activitypub_json, mention.status.account_id, mentioned_account.inbox_url, { synchronize_followers: !mention.status.distributable? })
ActivityPub::DeliveryWorker.perform_async(activitypub_json, mention.status.account_id, mentioned_account.inbox_url)
end
end

10 changes: 0 additions & 10 deletions app/workers/activitypub/delivery_worker.rb
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

class ActivityPub::DeliveryWorker
include Sidekiq::Worker
include RoutingHelper
include JsonLdHelper

STOPLIGHT_FAILURE_THRESHOLD = 10
@@ -39,18 +38,9 @@ def build_request(http_client)
Request.new(:post, @inbox_url, body: @json, http_client: http_client).tap do |request|
request.on_behalf_of(@source_account, :uri, sign_with: @options[:sign_with])
request.add_headers(HEADERS)
request.add_headers({ 'Collection-Synchronization' => synchronization_header }) if ENV['DISABLE_FOLLOWERS_SYNCHRONIZATION'] != 'true' && @options[:synchronize_followers]
end
end

def synchronization_header
"collectionId=\"#{account_followers_url(@source_account)}\", digest=\"#{@source_account.remote_followers_hash(inbox_url_prefix)}\", url=\"#{account_followers_synchronization_url(@source_account)}\""
end

def inbox_url_prefix
@inbox_url[/http(s?):\/\/[^\/]+\//]
end

def perform_request
light = Stoplight(@inbox_url) do
request_pool.with(@host) do |http_client|
2 changes: 1 addition & 1 deletion app/workers/activitypub/distribution_worker.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ def perform(status_id)
return if skip_distribution?

ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
[payload, @account.id, inbox_url, { synchronize_followers: !@status.distributable? }]
[payload, @account.id, inbox_url]
end

relay! if relayable?
14 changes: 0 additions & 14 deletions app/workers/activitypub/followers_synchronization_worker.rb

This file was deleted.

Loading

0 comments on commit be70c76

Please sign in to comment.