Change: #70 DTL投稿で、公開範囲・検索許可を別々に設定 (#177)

* Bump version to 8.0

* Add: 他のサーバーに公開する情報に、制限設定などを追加

* Fix: `quote_of_id`のインデックス

* Fix: #172 他のサーバーからの相乗り絵文字削除が反映されない

* Test: #166 リモートから自分の絵文字を受け取った時、ライセンスが上書きされないことを確認するテスト

* Change: #70 DTL投稿で、公開範囲・検索許可を別々に設定
This commit is contained in:
KMY(雪あすか) 2023-10-26 22:06:51 +09:00 committed by GitHub
parent e32f00b275
commit ae865975d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 19 deletions

View file

@ -0,0 +1,52 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class ConvertDtlForceSettings < ActiveRecord::Migration[7.0]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
class User < ApplicationRecord; end
def up
safety_assured do
User.transaction do
User.find_in_batches do |users|
users.filter { |user| user.settings.present? }.each do |user|
json = Oj.load(user.settings, symbol_keys: true)
dtl_force_with_tag = json.delete(:dtl_force_with_tag)
next if dtl_force_with_tag.blank?
json[:dtl_force_visibility] = dtl_force_with_tag == 'full' ? 'unlisted' : 'unchange'
json[:dtl_force_searchability] = dtl_force_with_tag == 'none' ? 'unchange' : 'public'
user.update(settings: Oj.dump(json))
end
end
end
end
end
def down
safety_assured do
User.transaction do
User.find_in_batches do |users|
users.filter { |user| user.settings.present? }.each do |user|
json = Oj.load(user.settings, symbol_keys: true)
dtl_force_visibility = json.delete(:dtl_force_visibility)
dtl_force_searchability = json.delete(:dtl_force_searchability)
next unless dtl_force_visibility.present? || dtl_force_searchability.present?
json[:dtl_force_with_tag] = case dtl_force_visibility
when 'unlisted'
'full'
else
dtl_force_searchability == 'unchange' ? 'none' : 'searchability'
end
user.update(settings: Oj.dump(json))
end
end
end
end
end
end

View file

@ -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_10_22_074913) do
ActiveRecord::Schema[7.0].define(version: 2023_10_23_083359) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"