Add: #437 ドメインブロックで「未ログインユーザーに非公開」の設定を「非公開」にコピーするマイグレーションコード
This commit is contained in:
parent
267e9cbcc8
commit
7edb05337e
5 changed files with 23 additions and 6 deletions
|
@ -442,6 +442,7 @@ Rails/SkipsModelValidations:
|
|||
- 'db/migrate/20190511134027_add_silenced_at_suspended_at_to_accounts.rb'
|
||||
- 'db/migrate/20191007013357_update_pt_locales.rb'
|
||||
- 'db/migrate/20220316233212_update_kurdish_locales.rb'
|
||||
- 'db/migrate/20240109035435_remove_hidden_anonymous_from_domain_blocks.rb'
|
||||
- 'db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb'
|
||||
- 'db/post_migrate/20200917193528_migrate_notifications_type.rb'
|
||||
- 'db/post_migrate/20201017234926_fill_account_suspension_origin.rb'
|
||||
|
|
|
@ -70,7 +70,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||
|
||||
def domain_block_params
|
||||
params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
|
||||
:reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous)
|
||||
:reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
|
@ -103,6 +103,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||
|
||||
def resource_params
|
||||
params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
|
||||
:reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous)
|
||||
:reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
# reject_straight_follow :boolean default(FALSE), not null
|
||||
# reject_new_follow :boolean default(FALSE), not null
|
||||
# hidden :boolean default(FALSE), not null
|
||||
# hidden_anonymous :boolean default(FALSE), not null
|
||||
# detect_invalid_subscription :boolean default(FALSE), not null
|
||||
# reject_reply_exclude_followers :boolean default(FALSE), not null
|
||||
#
|
||||
|
@ -43,7 +42,7 @@ class DomainBlock < ApplicationRecord
|
|||
delegate :count, to: :accounts, prefix: true
|
||||
|
||||
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
||||
scope :with_user_facing_limitations, -> { where(hidden: false, hidden_anonymous: false) }
|
||||
scope :with_user_facing_limitations, -> { where(hidden: false) }
|
||||
scope :with_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)).or(where(reject_favourite: true)).or(where(reject_reply: true)).or(where(reject_reply_exclude_followers: true)).or(where(reject_new_follow: true)).or(where(reject_straight_follow: true)) }
|
||||
scope :by_severity, -> { order(Arel.sql('(CASE severity WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 0 END), domain')) }
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveHiddenAnonymousFromDomainBlocks < ActiveRecord::Migration[7.1]
|
||||
class DomainBlock < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
DomainBlock.where(hidden_anonymous: true, hidden: false).update_all(hidden: true)
|
||||
remove_column :domain_blocks, :hidden_anonymous
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
add_column :domain_blocks, :hidden_anonymous, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_12_12_225737) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_01_09_035435) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -570,7 +570,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_12_12_225737) do
|
|||
t.boolean "reject_straight_follow", default: false, null: false
|
||||
t.boolean "reject_new_follow", default: false, null: false
|
||||
t.boolean "hidden", default: false, null: false
|
||||
t.boolean "hidden_anonymous", default: false, null: false
|
||||
t.boolean "detect_invalid_subscription", default: false, null: false
|
||||
t.boolean "reject_reply_exclude_followers", default: false, null: false
|
||||
t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue