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
|
@ -36,8 +36,8 @@ class MigrateInteractionSettingsToPolicy < ActiveRecord::Migration[7.1]
|
|||
requires_new_policy = true
|
||||
end
|
||||
|
||||
if deserialized_settings['interactions.must_be_following_dm']
|
||||
policy.filter_private_mentions = true
|
||||
unless deserialized_settings['interactions.must_be_following_dm']
|
||||
policy.filter_private_mentions = false
|
||||
requires_new_policy = true
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateRelationshipSeveranceEvents < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :relationship_severance_events do |t|
|
||||
t.integer :type, null: false
|
||||
t.string :target_name, null: false
|
||||
t.boolean :purged, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
|
||||
t.index [:type, :target_name]
|
||||
end
|
||||
end
|
||||
end
|
27
db/migrate/20240312105620_create_severed_relationships.rb
Normal file
27
db/migrate/20240312105620_create_severed_relationships.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateSeveredRelationships < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :severed_relationships do |t|
|
||||
# No need to have an index on this foreign key as it is covered by `index_severed_relationships_on_unique_tuples`
|
||||
t.references :relationship_severance_event, null: false, foreign_key: { on_delete: :cascade }, index: false
|
||||
|
||||
# No need to have an index on this foregin key as it is covered by `index_severed_relationships_on_local_account_and_event`
|
||||
t.references :local_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }, index: false
|
||||
t.references :remote_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }
|
||||
|
||||
# Used to describe whether `local_account` is the active (follower) or passive (followed) part of the relationship
|
||||
t.integer :direction, null: false
|
||||
|
||||
# Those attributes are carried over from the `follows` table
|
||||
t.boolean :show_reblogs
|
||||
t.boolean :notify
|
||||
t.string :languages, array: true
|
||||
|
||||
t.timestamps
|
||||
|
||||
t.index [:relationship_severance_event_id, :local_account_id, :direction, :remote_account_id], name: 'index_severed_relationships_on_unique_tuples', unique: true
|
||||
t.index [:local_account_id, :relationship_severance_event_id], name: 'index_severed_relationships_on_local_account_and_event'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateAccountRelationshipSeveranceEvents < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :account_relationship_severance_events do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade }, null: false
|
||||
t.belongs_to :relationship_severance_event, foreign_key: { on_delete: :cascade }, null: false
|
||||
|
||||
t.integer :relationships_count, default: 0, null: false
|
||||
|
||||
t.index [:account_id, :relationship_severance_event_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangeNotificationRequestLastStatusIdNullable < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
change_column_null :notification_requests, :last_status_id, true
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddFollowersAndFollowingCountsToAccountRelationshipSeveranceEvents < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :account_relationship_severance_events, :followers_count, :integer, default: 0, null: false
|
||||
add_column :account_relationship_severance_events, :following_count, :integer, default: 0, null: false
|
||||
end
|
||||
end
|
|
@ -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
|
47
db/schema.rb
47
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_03_22_161611) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -90,6 +90,18 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
t.index ["target_account_id"], name: "index_account_pins_on_target_account_id"
|
||||
end
|
||||
|
||||
create_table "account_relationship_severance_events", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "relationship_severance_event_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "followers_count", default: 0, null: false
|
||||
t.integer "following_count", default: 0, null: false
|
||||
t.index ["account_id", "relationship_severance_event_id"], name: "idx_on_account_id_relationship_severance_event_id_7bd82bf20e", unique: true
|
||||
t.index ["account_id"], name: "index_account_relationship_severance_events_on_account_id"
|
||||
t.index ["relationship_severance_event_id"], name: "idx_on_relationship_severance_event_id_403f53e707"
|
||||
end
|
||||
|
||||
create_table "account_stats", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "statuses_count", default: 0, null: false
|
||||
|
@ -971,7 +983,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
create_table "notification_requests", id: :bigint, default: -> { "timestamp_id('notification_requests'::text)" }, force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "from_account_id", null: false
|
||||
t.bigint "last_status_id", null: false
|
||||
t.bigint "last_status_id"
|
||||
t.bigint "notifications_count", default: 0, null: false
|
||||
t.boolean "dismissed", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
|
@ -1175,6 +1187,15 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
t.string "url"
|
||||
end
|
||||
|
||||
create_table "relationship_severance_events", force: :cascade do |t|
|
||||
t.integer "type", null: false
|
||||
t.string "target_name", null: false
|
||||
t.boolean "purged", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["type", "target_name"], name: "index_relationship_severance_events_on_type_and_target_name"
|
||||
end
|
||||
|
||||
create_table "relays", force: :cascade do |t|
|
||||
t.string "inbox_url", default: "", null: false
|
||||
t.string "follow_activity_id"
|
||||
|
@ -1274,6 +1295,21 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
|
||||
end
|
||||
|
||||
create_table "severed_relationships", force: :cascade do |t|
|
||||
t.bigint "relationship_severance_event_id", null: false
|
||||
t.bigint "local_account_id", null: false
|
||||
t.bigint "remote_account_id", null: false
|
||||
t.integer "direction", null: false
|
||||
t.boolean "show_reblogs"
|
||||
t.boolean "notify"
|
||||
t.string "languages", array: true
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["local_account_id", "relationship_severance_event_id"], name: "index_severed_relationships_on_local_account_and_event"
|
||||
t.index ["relationship_severance_event_id", "local_account_id", "direction", "remote_account_id"], name: "index_severed_relationships_on_unique_tuples", unique: true
|
||||
t.index ["remote_account_id"], name: "index_severed_relationships_on_remote_account_id"
|
||||
end
|
||||
|
||||
create_table "site_uploads", force: :cascade do |t|
|
||||
t.string "var", default: "", null: false
|
||||
t.string "file_file_name"
|
||||
|
@ -1490,7 +1526,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.datetime "current_sign_in_at", precision: nil
|
||||
t.datetime "last_sign_in_at", precision: nil
|
||||
t.boolean "admin", default: false, null: false
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at", precision: nil
|
||||
t.datetime "confirmation_sent_at", precision: nil
|
||||
|
@ -1505,7 +1540,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
t.string "otp_backup_codes", array: true
|
||||
t.bigint "account_id", null: false
|
||||
t.boolean "disabled", default: false, null: false
|
||||
t.boolean "moderator", default: false, null: false
|
||||
t.bigint "invite_id"
|
||||
t.string "chosen_languages", array: true
|
||||
t.bigint "created_by_application_id"
|
||||
|
@ -1584,6 +1618,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
add_foreign_key "account_notes", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "account_pins", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_relationship_severance_events", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_relationship_severance_events", "relationship_severance_events", on_delete: :cascade
|
||||
add_foreign_key "account_stats", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
|
@ -1705,6 +1741,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_231633) do
|
|||
add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
|
||||
add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
|
||||
add_foreign_key "severed_relationships", "accounts", column: "local_account_id", on_delete: :cascade
|
||||
add_foreign_key "severed_relationships", "accounts", column: "remote_account_id", on_delete: :cascade
|
||||
add_foreign_key "severed_relationships", "relationship_severance_events", on_delete: :cascade
|
||||
add_foreign_key "status_capability_tokens", "statuses", on_delete: :cascade
|
||||
add_foreign_key "status_edits", "accounts", on_delete: :nullify
|
||||
add_foreign_key "status_edits", "statuses", on_delete: :cascade
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue