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
|
@ -0,0 +1,54 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MigrateInteractionSettingsToPolicyAgain < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
# Dummy classes, to make migration possible across version changes
|
||||
class Account < ApplicationRecord
|
||||
has_one :user, inverse_of: :account
|
||||
has_one :notification_policy, inverse_of: :account
|
||||
end
|
||||
|
||||
class User < ApplicationRecord
|
||||
belongs_to :account
|
||||
end
|
||||
|
||||
class NotificationPolicy < ApplicationRecord
|
||||
belongs_to :account
|
||||
end
|
||||
|
||||
def up
|
||||
User.includes(account: :notification_policy).find_each do |user|
|
||||
deserialized_settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
|
||||
next if deserialized_settings.nil?
|
||||
|
||||
# If the user has configured a notification policy, don't override it
|
||||
next if user.account.notification_policy.present?
|
||||
|
||||
policy = user.account.build_notification_policy
|
||||
requires_new_policy = false
|
||||
|
||||
if deserialized_settings['interactions.must_be_follower']
|
||||
policy.filter_not_followers = true
|
||||
requires_new_policy = true
|
||||
end
|
||||
|
||||
if deserialized_settings['interactions.must_be_following']
|
||||
policy.filter_not_following = true
|
||||
requires_new_policy = true
|
||||
end
|
||||
|
||||
unless deserialized_settings['interactions.must_be_following_dm']
|
||||
policy.filter_private_mentions = false
|
||||
requires_new_policy = true
|
||||
end
|
||||
|
||||
policy.save if requires_new_policy && policy.changed?
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
def down; end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveRelationshipsCountFromAccountRelationshipSeveranceEvents < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
safety_assured { remove_column :account_relationship_severance_events, :relationships_count, :integer, default: 0, null: false }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveObsoleteRolesFromUsers < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
safety_assured { remove_column :users, :admin, :boolean, default: false, null: false }
|
||||
safety_assured { remove_column :users, :moderator, :boolean, default: false, null: false }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue