diff options
author | Claire <claire.github-309c@sitedethib.com> | 2020-12-05 17:33:29 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2020-12-05 17:33:37 +0100 |
commit | f8d867bac43e7e18d293ac32a9be597d1f46dce3 (patch) | |
tree | b3d950a01a8dee5403081f56cf0c6b0571954e90 /lib | |
parent | 13df125b6c75923ccc21a5c57053e680cea75f38 (diff) | |
parent | 44d5c6bc8ffd92cd201380dabe35748e50b6af68 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/services/remove_status_service.rb`: Conflict caused by us having a distinc Direct timeline. Ported upstream changes. - `app/javascript/mastodon/features/compose/components/compose_form.js`: Conflict between glitch-soc's variable character limit and upstream refactoring that part of the code. Ported upstream changes.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mastodon/ip_blocks_cli.rb | 2 | ||||
-rw-r--r-- | lib/mastodon/maintenance_cli.rb | 45 | ||||
-rw-r--r-- | lib/mastodon/version.rb | 4 | ||||
-rw-r--r-- | lib/tasks/db.rake | 7 |
4 files changed, 52 insertions, 6 deletions
diff --git a/lib/mastodon/ip_blocks_cli.rb b/lib/mastodon/ip_blocks_cli.rb index 6aff36d90..5c38c1aca 100644 --- a/lib/mastodon/ip_blocks_cli.rb +++ b/lib/mastodon/ip_blocks_cli.rb @@ -47,7 +47,7 @@ module Mastodon ip_block ||= IpBlock.new(ip: address) ip_block.severity = options[:severity] - ip_block.comment = options[:comment] + ip_block.comment = options[:comment] if options[:comment].present? ip_block.expires_in = options[:duration] if ip_block.save diff --git a/lib/mastodon/maintenance_cli.rb b/lib/mastodon/maintenance_cli.rb index 547238ec6..99d13f43d 100644 --- a/lib/mastodon/maintenance_cli.rb +++ b/lib/mastodon/maintenance_cli.rb @@ -55,8 +55,8 @@ module Mastodon belongs_to :account, inverse_of: :account_stat end + # Dummy class, to make migration possible across version changes class Account < ApplicationRecord - # Dummy class, to make migration possible across version changes has_one :user, inverse_of: :account has_one :account_stat, inverse_of: :account @@ -69,6 +69,49 @@ module Mastodon def acct local? ? username : "#{username}@#{domain}" end + + # This is a duplicate of the AccountMerging concern because we need it to + # be independent from code version. + def merge_with!(other_account) + # Since it's the same remote resource, the remote resource likely + # already believes we are following/blocking, so it's safe to + # re-attribute the relationships too. However, during the presence + # of the index bug users could have *also* followed the reference + # account already, therefore mass update will not work and we need + # to check for (and skip past) uniqueness errors + + owned_classes = [ + Status, StatusPin, MediaAttachment, Poll, Report, Tombstone, Favourite, + Follow, FollowRequest, Block, Mute, AccountIdentityProof, + AccountModerationNote, AccountPin, AccountStat, ListAccount, + PollVote, Mention + ] + owned_classes << AccountDeletionRequest if ActiveRecord::Base.connection.table_exists?(:account_deletion_requests) + owned_classes << AccountNote if ActiveRecord::Base.connection.table_exists?(:account_notes) + + owned_classes.each do |klass| + klass.where(account_id: other_account.id).find_each do |record| + begin + record.update_attribute(:account_id, id) + rescue ActiveRecord::RecordNotUnique + next + end + end + end + + target_classes = [Follow, FollowRequest, Block, Mute, AccountModerationNote, AccountPin] + target_classes << AccountNote if ActiveRecord::Base.connection.table_exists?(:account_notes) + + target_classes.each do |klass| + klass.where(target_account_id: other_account.id).find_each do |record| + begin + record.update_attribute(:target_account_id, id) + rescue ActiveRecord::RecordNotUnique + next + end + end + end + end end class User < ApplicationRecord diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 429bcb8a5..84f7f1961 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -9,7 +9,7 @@ module Mastodon end def minor - 2 + 3 end def patch @@ -17,7 +17,7 @@ module Mastodon end def flags - '' + 'rc1' end def suffix diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 199155107..f6c9c7eec 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -51,8 +51,11 @@ namespace :db do task :post_migration_hook do at_exit do unless %w(C POSIX).include?(ActiveRecord::Base.connection.execute('SELECT datcollate FROM pg_database WHERE datname = current_database();').first['datcollate']) - Rails.logger.warn 'WARNING: Your database is using an unsafe collation setting, which might result in index corruption.' - Rails.logger.warn 'WARNING: See https://docs.joinmastodon.org/admin/troubleshooting/index-corruption/#am-i-affected' + warn <<~WARNING + Your database collation is susceptible to index corruption. + (This warning does not indicate that index corruption has occured and can be ignored) + (To learn more, visit: https://docs.joinmastodon.org/admin/troubleshooting/index-corruption/) + WARNING end end end |