Merge remote-tracking branch 'parent/main' into upstream-20240326
This commit is contained in:
commit
6c9b221cb2
263 changed files with 4628 additions and 1518 deletions
|
@ -5,7 +5,7 @@ require_relative 'base'
|
|||
module Mastodon::CLI
|
||||
class Maintenance < Base
|
||||
MIN_SUPPORTED_VERSION = 2019_10_01_213028
|
||||
MAX_SUPPORTED_VERSION = 2023_09_07_150100
|
||||
MAX_SUPPORTED_VERSION = 2023_10_23_105620
|
||||
|
||||
# Stubs to enjoy ActiveRecord queries while not depending on a particular
|
||||
# version of the code/database
|
||||
|
@ -26,6 +26,9 @@ module Mastodon::CLI
|
|||
class ListAccount < ApplicationRecord; end
|
||||
class PollVote < ApplicationRecord; end
|
||||
class Mention < ApplicationRecord; end
|
||||
class Notification < ApplicationRecord; end
|
||||
class NotificationPermission < ApplicationRecord; end
|
||||
class NotificationRequest < ApplicationRecord; end
|
||||
class AccountDomainBlock < ApplicationRecord; end
|
||||
class AnnouncementReaction < ApplicationRecord; end
|
||||
class FeaturedTag < ApplicationRecord; end
|
||||
|
@ -39,9 +42,10 @@ module Mastodon::CLI
|
|||
class Webhook < ApplicationRecord; end
|
||||
class BulkImport < ApplicationRecord; end
|
||||
class SoftwareUpdate < ApplicationRecord; end
|
||||
class SeveredRelationship < ApplicationRecord; end
|
||||
|
||||
class DomainBlock < ApplicationRecord
|
||||
enum severity: { silence: 0, suspend: 1, noop: 2 }
|
||||
enum :severity, { silence: 0, suspend: 1, noop: 2 }
|
||||
scope :by_severity, -> { in_order_of(:severity, %w(noop silence suspend)).order(:domain) }
|
||||
end
|
||||
|
||||
|
@ -107,6 +111,18 @@ module Mastodon::CLI
|
|||
end
|
||||
end
|
||||
|
||||
from_classes = [Notification]
|
||||
from_classes << NotificationPermission if db_table_exists?(:notification_permissions)
|
||||
from_classes << NotificationRequest if db_table_exists?(:notification_requests)
|
||||
|
||||
from_classes.each do |klass|
|
||||
klass.where(from_account_id: other_account.id).find_each do |record|
|
||||
record.update_attribute(:from_account_id, id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
target_classes = [Follow, FollowRequest, Block, Mute, AccountModerationNote, AccountPin]
|
||||
target_classes << AccountNote if db_table_exists?(:account_notes)
|
||||
|
||||
|
@ -129,6 +145,20 @@ module Mastodon::CLI
|
|||
record.update_attribute(:account_warning_id, id)
|
||||
end
|
||||
end
|
||||
|
||||
if db_table_exists?(:severed_relationships)
|
||||
SeveredRelationship.where(local_account_id: other_account.id).reorder(nil).find_each do |record|
|
||||
record.update_attribute(:local_account_id, id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
|
||||
SeveredRelationship.where(remote_account_id: other_account.id).reorder(nil).find_each do |record|
|
||||
record.update_attribute(:remote_account_id, id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -105,6 +105,12 @@ namespace :tests do
|
|||
exit(1)
|
||||
end
|
||||
|
||||
policy = NotificationPolicy.find_by(account: User.find(1).account)
|
||||
unless policy.filter_private_mentions == false && policy.filter_not_following == true
|
||||
puts 'Notification policy not migrated as expected'
|
||||
exit(1)
|
||||
end
|
||||
|
||||
puts 'No errors found. Database state is consistent with a successful migration process.'
|
||||
end
|
||||
|
||||
|
@ -181,7 +187,8 @@ namespace :tests do
|
|||
INSERT INTO "settings"
|
||||
(id, thing_type, thing_id, var, value, created_at, updated_at)
|
||||
VALUES
|
||||
(5, 'User', 4, 'default_language', E'--- kmr\n', now(), now());
|
||||
(5, 'User', 4, 'default_language', E'--- kmr\n', now(), now()),
|
||||
(6, 'User', 1, 'interactions', E'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nmust_be_follower: false\nmust_be_following: true\nmust_be_following_dm: false\n', now(), now());
|
||||
SQL
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue