From 86792bd309f3b49c924b6a9fc08313886a916dc6 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 24 Aug 2018 18:17:11 +0200 Subject: [PATCH 1/6] Upgrade Doorkeeper to 5.0.0 (#8409) See doorkeeper-gem/doorkeeper#1137 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c9e74455a..15f2af41c 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ gem 'omniauth-cas', '~> 1.1' gem 'omniauth-saml', '~> 1.10' gem 'omniauth', '~> 1.2' -gem 'doorkeeper', '~> 4.4' +gem 'doorkeeper', '~> 5.0' gem 'fast_blank', '~> 1.0' gem 'fastimage' gem 'goldfinger', '~> 2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 2da3fe324..945c0776e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -181,7 +181,7 @@ GEM docile (1.3.0) domain_name (0.5.20180417) unf (>= 0.0.5, < 1.0.0) - doorkeeper (4.4.2) + doorkeeper (5.0.0) railties (>= 4.2) dotenv (2.2.2) dotenv-rails (2.2.2) @@ -670,7 +670,7 @@ DEPENDENCIES devise (~> 4.4) devise-two-factor (~> 3.0) devise_pam_authenticatable2 (~> 9.1) - doorkeeper (~> 4.4) + doorkeeper (~> 5.0) dotenv-rails (~> 2.2, < 2.3) fabrication (~> 2.20) faker (~> 1.8) From 3f4812c5832ebc98a79746120bfef0d2b15286af Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sun, 15 Jul 2018 21:56:00 +0900 Subject: [PATCH 2/6] Fix index detection a migration to revert index change (#8026) --- ...hange_on_statuses_for_api_v1_accounts_account_id_statuses.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb index 4a8761fec..ccd2ec7ea 100644 --- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -5,7 +5,7 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor def change safety_assured do - add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_exists?(:statuses, name: "index_statuses_20180106") + add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, "index_statuses_20180106") end # These index may not exists (see migration 20180514130000) From f6ad5edbaa178a120d281840f6650f8213bcd8bf Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 11 Aug 2018 18:00:41 +0200 Subject: [PATCH 3/6] Make some migration script more robust (fixes #8007) (#8170) Include a dummy Account class in the migration script containing only the attributes relevant to the migration in order to not rely as much on the codebase being in sync with the database schema. --- db/migrate/20180528141303_fix_accounts_unique_index.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/db/migrate/20180528141303_fix_accounts_unique_index.rb b/db/migrate/20180528141303_fix_accounts_unique_index.rb index 96cee37f9..624ea229e 100644 --- a/db/migrate/20180528141303_fix_accounts_unique_index.rb +++ b/db/migrate/20180528141303_fix_accounts_unique_index.rb @@ -1,4 +1,13 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2] + class Account < ApplicationRecord + # Dummy class, to make migration possible across version changes + has_one :user, inverse_of: :account + + def local? + domain.nil? + end + end + disable_ddl_transaction! def up From a16d41e9fbacac1c0e1a5557c1a0a140530e2713 Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 15 Aug 2018 20:23:12 +0200 Subject: [PATCH 4/6] Fix FixAccountsUniqueIndex migration (#8212) --- db/migrate/20180528141303_fix_accounts_unique_index.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/migrate/20180528141303_fix_accounts_unique_index.rb b/db/migrate/20180528141303_fix_accounts_unique_index.rb index 624ea229e..bd4e158b7 100644 --- a/db/migrate/20180528141303_fix_accounts_unique_index.rb +++ b/db/migrate/20180528141303_fix_accounts_unique_index.rb @@ -6,6 +6,10 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2] def local? domain.nil? end + + def acct + local? ? username : "#{username}@#{domain}" + end end disable_ddl_transaction! From 221c8c771f0a275e4924f038b71c52dd4bf93b5f Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 28 Jul 2018 23:14:55 +0200 Subject: [PATCH 5/6] Prevent ActivityPub movedTo recursion (#8092) Fix #8051 --- app/services/activitypub/fetch_remote_account_service.rb | 4 ++-- app/services/activitypub/process_account_service.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/activitypub/fetch_remote_account_service.rb b/app/services/activitypub/fetch_remote_account_service.rb index 6fa4e9a1b..1ec9ee5dd 100644 --- a/app/services/activitypub/fetch_remote_account_service.rb +++ b/app/services/activitypub/fetch_remote_account_service.rb @@ -7,14 +7,14 @@ class ActivityPub::FetchRemoteAccountService < BaseService # Should be called when uri has already been checked for locality # Does a WebFinger roundtrip on each call - def call(uri, id: true, prefetched_body: nil) + def call(uri, id: true, prefetched_body: nil, break_on_redirect: false) @json = if prefetched_body.nil? fetch_resource(uri, id) else body_to_json(prefetched_body, compare_id: id ? uri : nil) end - return unless supported_context? && expected_type? + return if !supported_context? || !expected_type? || (break_on_redirect && @json['movedTo'].present?) @uri = @json['id'] @username = @json['preferredUsername'] diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 453253db4..7f95678b0 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -175,7 +175,7 @@ class ActivityPub::ProcessAccountService < BaseService def moved_account account = ActivityPub::TagManager.instance.uri_to_resource(@json['movedTo'], Account) - account ||= ActivityPub::FetchRemoteAccountService.new.call(@json['movedTo'], id: true) + account ||= ActivityPub::FetchRemoteAccountService.new.call(@json['movedTo'], id: true, break_on_redirect: true) account end From add3b63a0c84dbad936c461ae2617b1f995fe85b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 24 Aug 2018 20:11:40 +0200 Subject: [PATCH 6/6] Bump version to 2.4.5 --- lib/mastodon/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 87099675b..38debbd6e 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -13,7 +13,7 @@ module Mastodon end def patch - 4 + 5 end def pre