* Wip: マイグレーション、設定など一式 * Fix test * Fix test * Fix: マスター用の設定を他サーバーに送信しないよう修正 * DTL、外部サーバーの情報受け入れのテストを追加 * スペルミスを修正 * Web画面に設定項目追加 * 既存の`master_settings`を上書きしないよう修正
This commit is contained in:
parent
a7dec3c59b
commit
76f2f2ed0c
26 changed files with 284 additions and 52 deletions
43
db/migrate/20231105225839_add_master_settings_to_accounts.rb
Normal file
43
db/migrate/20231105225839_add_master_settings_to_accounts.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddMasterSettingsToAccounts < ActiveRecord::Migration[7.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class Account < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :accounts, :master_settings, :jsonb
|
||||
|
||||
Account.transaction do
|
||||
Account.find_in_batches do |accounts|
|
||||
accounts.each do |account|
|
||||
account.update(master_settings: { 'subscription_policy' => account.dissubscribable ? 'block' : 'allow' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :accounts, :dissubscribable
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
add_column_with_default :accounts, :dissubscribable, :boolean, default: false, allow_null: false
|
||||
|
||||
Account.transaction do
|
||||
Account.find_in_batches do |accounts|
|
||||
accounts.each do |account|
|
||||
account.update(dissubscribable: account.master_settings.present? && account.master_settings['subscription_policy'] != 'allow')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :accounts, :master_settings
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2023_10_28_005948) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2023_11_05_225839) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -200,9 +200,9 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_28_005948) do
|
|||
t.datetime "requested_review_at", precision: nil
|
||||
t.boolean "group_allow_private_message"
|
||||
t.integer "searchability", default: 2, null: false
|
||||
t.boolean "dissubscribable", default: false, null: false
|
||||
t.jsonb "settings"
|
||||
t.boolean "indexable", default: false, null: false
|
||||
t.jsonb "master_settings"
|
||||
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
|
||||
t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
|
||||
t.index ["domain", "id"], name: "index_accounts_on_domain_and_id"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue