mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Use JSON.generate in db migrations (#38241)
This commit is contained in:
@@ -28,7 +28,7 @@ class RejectFollowingBlockedUsers < ActiveRecord::Migration[5.2]
|
||||
|
||||
next follow.destroy! if blocked_account.local?
|
||||
|
||||
reject_follow_json = Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(follow, serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(followed_account))
|
||||
reject_follow_json = JSON.generate(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(follow, serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(followed_account))
|
||||
|
||||
ActivityPub::DeliveryWorker.perform_async(reject_follow_json, followed_account, blocked_account.inbox_url)
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
|
||||
end
|
||||
end
|
||||
|
||||
user.update_column('settings', Oj.dump(user_settings))
|
||||
user.update_column('settings', JSON.generate(user_settings))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ class MigrateInteractionSettingsToPolicy < ActiveRecord::Migration[7.1]
|
||||
private
|
||||
|
||||
def policy_for_user(user)
|
||||
deserialized_settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
deserialized_settings = JSON.parse(user.attributes_before_type_cast['settings'])
|
||||
return if deserialized_settings.nil?
|
||||
|
||||
requires_new_policy = false
|
||||
|
||||
@@ -8,7 +8,7 @@ class FillDefaultQuotePolicySetting < ActiveRecord::Migration[8.0]
|
||||
|
||||
def up
|
||||
User.where.not(settings: nil).find_each do |user|
|
||||
settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
settings = JSON.parse(user.attributes_before_type_cast['settings'])
|
||||
next if settings.nil?
|
||||
|
||||
should_update_settings = false
|
||||
@@ -26,7 +26,7 @@ class FillDefaultQuotePolicySetting < ActiveRecord::Migration[8.0]
|
||||
should_update_settings = true
|
||||
end
|
||||
|
||||
user.update_column('settings', Oj.dump(settings)) if should_update_settings
|
||||
user.update_column('settings', JSON.generate(settings)) if should_update_settings
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class MigrateUserTheme < ActiveRecord::Migration[8.0]
|
||||
|
||||
def up
|
||||
User.where.not(settings: nil).find_each do |user|
|
||||
settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
settings = JSON.parse(user.attributes_before_type_cast['settings'])
|
||||
next if settings.nil? || settings['theme'].blank? || %w(system default mastodon-light contrast).exclude?(settings['theme'])
|
||||
|
||||
case settings['theme']
|
||||
@@ -25,7 +25,7 @@ class MigrateUserTheme < ActiveRecord::Migration[8.0]
|
||||
|
||||
settings['theme'] = 'default'
|
||||
|
||||
user.update_column('settings', Oj.dump(settings))
|
||||
user.update_column('settings', JSON.generate(settings))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,11 +11,11 @@ class FixKmrLocaleSettings < ActiveRecord::Migration[7.0]
|
||||
MigrationUser.reset_column_information
|
||||
|
||||
MigrationUser.where.not(settings: [nil, '{}']).find_each do |user|
|
||||
user_settings = Oj.load(user.settings)
|
||||
user_settings = JSON.parse(user.settings)
|
||||
next unless user_settings['default_language'] == 'kmr'
|
||||
|
||||
user_settings['default_language'] = 'ku'
|
||||
user.update!(settings: Oj.dump(user_settings))
|
||||
user.update!(settings: JSON.generate(user_settings))
|
||||
end
|
||||
|
||||
MigrationUser.where.not(chosen_languages: nil).where('chosen_languages && ?', '{kmr}').find_each do |user|
|
||||
|
||||
@@ -21,7 +21,7 @@ class MigrateInteractionSettingsToPolicyAgain < ActiveRecord::Migration[7.1]
|
||||
private
|
||||
|
||||
def policy_for_user(user)
|
||||
deserialized_settings = Oj.load(user.attributes_before_type_cast['settings'])
|
||||
deserialized_settings = JSON.parse(user.attributes_before_type_cast['settings'])
|
||||
return if deserialized_settings.nil?
|
||||
return if user.notification_policy.present?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user