Merge commit '0ad2413b35287958f59073a5b63aecc659a64d98' into glitch-soc/merge-upstream

Conflicts:
- `app/javascript/styles/mastodon/forms.scss`:
  Conflict because we ran eslint autofix on upstream files.
- `config/initializers/content_security_policy.rb`:
  Code style changes but we have a different version.
  Kept our version.
- `streaming/index.js`:
  Upstream fixed a typo close to glitch-soc-only code.
  Applied upstream's changes.
This commit is contained in:
Claire
2023-05-08 15:28:36 +02:00
209 changed files with 987 additions and 1098 deletions

View File

@@ -4,7 +4,7 @@ class StatusIdsToTimestampIds < ActiveRecord::Migration[5.1]
Mastodon::Snowflake.define_timestamp_id
# Set up the statuses.id column to use our timestamp-based IDs.
ActiveRecord::Base.connection.execute(<<~SQL)
ActiveRecord::Base.connection.execute(<<~SQL.squish)
ALTER TABLE statuses
ALTER COLUMN id
SET DEFAULT timestamp_id('statuses')
@@ -21,7 +21,7 @@ class StatusIdsToTimestampIds < ActiveRecord::Migration[5.1]
# We lock the table during this so that the ID won't get clobbered,
# but ID is indexed, so this should be a fast operation.
ActiveRecord::Base.connection.execute(<<~SQL)
ActiveRecord::Base.connection.execute(<<~SQL.squish)
LOCK statuses;
SELECT setval('statuses_id_seq', (SELECT MAX(id) FROM statuses));
ALTER TABLE statuses

View File

@@ -2,14 +2,14 @@ class RejectFollowingBlockedUsers < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
blocked_follows = Follow.find_by_sql(<<-SQL)
blocked_follows = Follow.find_by_sql(<<-SQL.squish)
select f.* from follows f
inner join blocks b on
f.account_id = b.target_account_id and
f.target_account_id = b.account_id
SQL
domain_blocked_follows = Follow.find_by_sql(<<-SQL)
domain_blocked_follows = Follow.find_by_sql(<<-SQL.squish)
select f.* from follows f
inner join accounts following on f.account_id = following.id
inner join account_domain_blocks b on

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class MoveUserSettings < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
class User < ApplicationRecord; end
MAPPING = {
@@ -57,26 +59,29 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
end
def up
User.find_each do |user|
previous_settings = LegacySetting.where(thing_type: 'User', thing_id: user.id).index_by(&:var)
User.find_in_batches do |users|
previous_settings_for_batch = LegacySetting.where(thing_type: 'User', thing_id: users.map(&:id)).group_by(&:thing_id)
user_settings = {}
users.each do |user|
previous_settings = previous_settings_for_batch[user.id]&.index_by(&:var) || {}
user_settings = {}
MAPPING.each do |legacy_key, new_key|
value = previous_settings[legacy_key]&.value
MAPPING.each do |legacy_key, new_key|
value = previous_settings[legacy_key]&.value
next if value.blank?
next if value.blank?
if value.is_a?(Hash)
value.each do |nested_key, nested_value|
user_settings[MAPPING[legacy_key][nested_key.to_sym]] = nested_value
if value.is_a?(Hash)
value.each do |nested_key, nested_value|
user_settings[MAPPING[legacy_key][nested_key.to_sym]] = nested_value
end
else
user_settings[new_key] = value
end
else
user_settings[new_key] = value
end
end
user.update_column('settings', Oj.dump(user_settings)) # rubocop:disable Rails/SkipsModelValidations
user.update_column('settings', Oj.dump(user_settings)) # rubocop:disable Rails/SkipsModelValidations
end
end
end