diff --git a/app/models/concerns/has_user_settings.rb b/app/models/concerns/has_user_settings.rb index 1aab66c0397ce4..dda0f97eeefc87 100644 --- a/app/models/concerns/has_user_settings.rb +++ b/app/models/concerns/has_user_settings.rb @@ -143,8 +143,12 @@ def setting_link_preview settings['link_preview'] end - def setting_dtl_force_with_tag - settings['dtl_force_with_tag']&.to_sym || :none + def setting_dtl_force_visibility + settings['dtl_force_visibility']&.to_sym || :unchange + end + + def setting_dtl_force_searchability + settings['dtl_force_searchability']&.to_sym || :unchange end def setting_dtl_force_subscribable diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index e353ec7b2a7d53..6c25b61367e2fb 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -38,7 +38,8 @@ class KeyError < Error; end setting :emoji_reaction_streaming_notify_impl2, default: false setting :emoji_reaction_policy, default: :allow, in: %w(allow outside_only followers_only following_only mutuals_only block) setting :unsafe_limited_distribution, default: false - setting :dtl_force_with_tag, default: :none, in: %w(full searchability none) + setting :dtl_force_visibility, default: :unchange, in: %w(unchange public public_unlisted unlisted) + setting :dtl_force_searchability, default: :unchange, in: %w(unchange public public_unlisted) setting :dtl_force_subscribable, default: false setting :lock_follow_from_bot, default: false setting :allow_quote, default: true diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 0e3bd8805de509..57ca1b940fc92c 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -111,8 +111,8 @@ def overwrite_dtl_post return if raw_tags.exclude?(DTL_TAG) return unless %i(public public_unlisted unlisted).include?(@visibility) - @visibility = :unlisted if @account.user&.setting_dtl_force_with_tag == :full - @searchability = :public if %i(full searchability).include?(@account.user&.setting_dtl_force_with_tag) + @visibility = @account.user&.setting_dtl_force_visibility if %i(public public_unlisted unlisted).include?(@account.user&.setting_dtl_force_visibility) + @searchability = @account.user&.setting_dtl_force_searchability if %i(public public_unlisted).include?(@account.user&.setting_dtl_force_searchability) @dtl = true end diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index e0ca7e433265fb..64a5789d732a0a 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -38,7 +38,10 @@ = ff.input :'web.enable_dtl_menu', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_dtl_menu') .fields-group - = ff.input :dtl_force_with_tag, kmyblue: true, collection: %w(full searchability none), label_method: ->(item) { safe_join([t("simple_form.labels.dtl_force_with_tag.#{item}")]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_dtl_force_with_tag'), hint: I18n.t('simple_form.hints.defaults.setting_dtl_force_with_tag', tag: @dtl_tag) + = ff.input :dtl_force_visibility, kmyblue: true, collection: %w(unchange public public_unlisted unlisted), label_method: ->(item) { safe_join([t("simple_form.labels.dtl_force_visibility.#{item}")]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_dtl_force_visibility'), hint: I18n.t('simple_form.hints.defaults.setting_dtl_force_visibility', tag: @dtl_tag) + + .fields-group + = ff.input :dtl_force_searchability, kmyblue: true, collection: %w(unchange public public_unlisted), label_method: ->(item) { safe_join([t("simple_form.labels.dtl_force_searchability.#{item}")]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_dtl_force_searchability'), hint: I18n.t('simple_form.hints.defaults.setting_dtl_force_searchability', tag: @dtl_tag) .fields-group = ff.input :dtl_force_subscribable, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_dtl_force_subscribable'), hint: I18n.t('simple_form.hints.defaults.setting_dtl_force_subscribable') diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 2b777aaa2b00c7..0c7ff8b3cd8c67 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -68,7 +68,8 @@ en: setting_display_media_hide_all: Always hide media setting_display_media_show_all: Always show media setting_dtl_force_subscribable: Your post can be detected local user's antenna to subscribe deep timeline - setting_dtl_force_with_tag: "With using #%{tag} tag, your post settings will be changed forcibly" + setting_dtl_force_searchability: "With using #%{tag} tag, your post settings will be changed forcibly" + setting_dtl_force_visibility: "With using #%{tag} tag, your post settings will be changed forcibly" setting_dtl_menu: Show DTL menu on web setting_emoji_reaction_policy: Even with this setting, users on other servers are free to put their stamp on the post and share it within the same server. If you simply want to remove the stamp from your own screen, you can disable it from the appearance settings setting_enable_emoji_reaction: If turn off, other users still can react your posts @@ -248,7 +249,8 @@ en: setting_display_media_hide_all: Hide all setting_display_media_show_all: Show all setting_dtl_force_subscribable: Ignore your dissubscribable setting when using the DTL tag - setting_dtl_force_with_tag: Post with DTL tag + setting_dtl_force_searchability: Post searchability + setting_dtl_force_visibility: Post visibility setting_emoji_reaction_streaming_notify_impl2: Enable stamp notification compat with Nyastodon, Catstodon, glitch-soc setting_enable_emoji_reaction: Use stamp function setting_enable_login_privacy: Enable login visibility @@ -299,10 +301,15 @@ en: username: Username username_or_email: Username or Email whole_word: Whole word - dtl_force_with_tag: - full: Visibility is unlisted, searchability is everyone - none: No changes - searchability: Searchability is everyone + dtl_force_searchability: + public: Everyone + public_unlisted: Local and followers + unchange: Unchange + dtl_force_visibility: + public: Public + public_unlisted: Public unlisted + unchange: Unchange + unlisted: Unlisted email_domain_block: with_dns_records: Include MX records and IPs of the domain emoji_reactions: diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index e474b47cbc8833..a38b698d452d15 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -74,7 +74,8 @@ ja: setting_display_media_hide_all: メディアを常に隠す setting_display_media_show_all: メディアを常に表示する setting_dtl_force_subscribable: 購読拒否設定に関係なく、ディープタイムラインに向けた投稿はアンテナに掲載されます。ディープタイムラインをアンテナ経由で閲覧している人にあなたの発言が届きます - setting_dtl_force_with_tag: "ハッシュタグ #%{tag} をつけて投稿するとき、公開範囲と検索許可を強制的に置き換えるかを設定します" + setting_dtl_force_searchability: "ハッシュタグ #%{tag} をつけて投稿するとき、検索許可を強制的に置き換えるかを設定します" + setting_dtl_force_visibility: "ハッシュタグ #%{tag} をつけて投稿するとき、公開範囲を強制的に置き換えるかを設定します" setting_emoji_reaction_policy: この設定をしても他のサーバーのユーザーはその投稿に自由にスタンプをつけ、同じサーバーの中で共有できます。単にあなた自身の画面からスタンプを除去したいだけなら、外観設定からスタンプを無効にすることができます setting_emoji_reaction_streaming_notify_impl2: 当該サーバーの独自機能に対応したアプリを利用時に、スタンプ機能を利用できます。動作確認していないため(そもそもそのようなアプリ自体を確認できていないため)正しく動かない場合があります setting_enable_emoji_reaction: この機能を無効にしても、他の人はあなたの投稿にスタンプをつけられます @@ -262,7 +263,8 @@ ja: setting_display_media_hide_all: 非表示 setting_display_media_show_all: 表示 setting_dtl_force_subscribable: ディープタイムライン用のハッシュタグを購読するアンテナに限り、購読拒否設定を無視する - setting_dtl_force_with_tag: DTL参加時の投稿設定 + setting_dtl_force_searchability: DTL投稿の検索許可 + setting_dtl_force_visibility: DTL投稿の公開範囲 setting_dtl_menu: Webクライアントのメニューにディープタイムラインを追加する setting_enable_login_privacy: 公開範囲「ログインユーザーのみ」をWeb UIで選択可能にする setting_emoji_reaction_policy: スタンプ受け入れと表示設定 @@ -315,10 +317,15 @@ ja: username: ユーザー名 username_or_email: ユーザー名またはメールアドレス whole_word: 単語全体にマッチ - dtl_force_with_tag: - full: 公開範囲「未収載」検索許可「誰でも」にする - none: 公開範囲も検索許可も変更しない - searchability: 検索許可を「誰でも」にする + dtl_force_searchability: + public: 誰でも + public_unlisted: ローカルとフォロワー + unchange: 変更しない + dtl_force_visibility: + public: 公開 + public_unlisted: ローカル公開 + unchange: 変更しない + unlisted: 非収載 email_domain_block: with_dns_records: ドメインのMXレコードとIPアドレスを含む emoji_reactions: diff --git a/db/migrate/20231023083359_convert_dtl_force_settings.rb b/db/migrate/20231023083359_convert_dtl_force_settings.rb new file mode 100644 index 00000000000000..165b73671e1ba8 --- /dev/null +++ b/db/migrate/20231023083359_convert_dtl_force_settings.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 071f29c2e0d91c..e43428edf863b7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"