Add default_reblog_privacy setting

This commit is contained in:
KMY 2023-05-18 09:43:26 +09:00
parent 922c936ef1
commit 5b51413be7
8 changed files with 22 additions and 4 deletions

View file

@ -151,6 +151,10 @@ module HasUserSettings
settings['default_privacy'] || (account.locked? ? 'private' : 'public')
end
def setting_default_reblog_privacy
settings['default_reblog_privacy'] || 'unset'
end
def setting_default_searchability
settings['default_searchability'] || 'private'
end

View file

@ -404,6 +404,10 @@ class Status < ApplicationRecord
visibilities.keys - %w(direct limited)
end
def selectable_reblog_visibilities
%w(unset) + visibilities.keys - %w(direct limited)
end
def selectable_searchabilities
searchabilities.keys - %w(public_unlisted limited)
end

View file

@ -19,6 +19,7 @@ class UserSettings
setting :default_language, default: nil
setting :default_sensitive, default: false
setting :default_privacy, default: nil
setting :default_reblog_privacy, default: nil
setting :default_searchability, default: :private
setting :public_post_to_unlisted, default: false
setting :reject_public_unlisted_subscription, default: false

View file

@ -23,7 +23,8 @@ class ReblogService < BaseService
visibility = if reblogged_status.hidden?
reblogged_status.visibility
else
options[:visibility] || account.user&.setting_default_privacy
options[:visibility] ||
(account.user&.setting_default_reblog_privacy == 'unset' ? account.user&.setting_default_privacy : account.user&.setting_default_reblog_privacy)
end
reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: visibility, rate_limit: options[:with_rate_limit])

View file

@ -24,10 +24,14 @@
= ff.input :default_privacy, collection: Status.selectable_visibilities, wrapper: :with_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_privacy')
.fields-group.fields-row__column.fields-row__column-6
= ff.input :default_language, collection: [nil] + filterable_languages, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, required: false, include_blank: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_language')
= ff.input :default_reblog_privacy, collection: Status.selectable_reblog_visibilities, wrapper: :with_label, kmyblue: true, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_reblog_privacy')
.fields-group
= ff.input :default_searchability, collection: Status.selectable_searchabilities, wrapper: :with_label, kmyblue: true, include_blank: false, label_method: lambda { |searchability| safe_join([I18n.t("statuses.searchabilities.#{searchability}"), I18n.t("statuses.searchabilities.#{searchability}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_searchability')
.fields-row
.fields-group.fields-row__column.fields-row__column-6
= ff.input :default_searchability, collection: Status.selectable_searchabilities, wrapper: :with_label, kmyblue: true, include_blank: false, label_method: lambda { |searchability| safe_join([I18n.t("statuses.searchabilities.#{searchability}"), I18n.t("statuses.searchabilities.#{searchability}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_searchability')
.fields-group.fields-row__column.fields-row__column-6
= ff.input :default_language, collection: [nil] + filterable_languages, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, required: false, include_blank: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_language')
.fields-group
= ff.input :public_post_to_unlisted, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_public_post_to_unlisted'), hint: I18n.t('simple_form.hints.defaults.setting_public_post_to_unlisted')

View file

@ -1662,6 +1662,8 @@ ja:
public_unlisted_long: 誰でも見ることができますが、連合タイムラインには表示されません
unlisted: 未収載
unlisted_long: 誰でも見ることができますが、連合・ローカルタイムラインには表示されません
unset: 設定なし
unset_long: デフォルトの挙動に従います
statuses_cleanup:
enabled: 古い投稿を自動的に削除する
enabled_hint: 設定した期間を過ぎた投稿は、以下の例外に該当しない限り、自動的に削除されます

View file

@ -209,6 +209,7 @@ en:
setting_crop_images: Crop images in non-expanded posts to 16x9
setting_default_language: Posting language
setting_default_privacy: Posting privacy
setting_default_reblog_privacy: Reblogging privacy
setting_default_searchability: Searchability
setting_default_sensitive: Always mark media as sensitive
setting_delete_modal: Show confirmation dialog before deleting a post

View file

@ -216,6 +216,7 @@ ja:
setting_crop_images: 投稿の詳細以外では画像を16:9に切り抜く
setting_default_language: 投稿する言語
setting_default_privacy: 投稿の公開範囲
setting_default_reblog_privacy: BTの公開範囲
setting_default_searchability: 投稿の検索を許可する範囲
setting_default_sensitive: メディアを常に閲覧注意としてマークする
setting_delete_modal: 投稿を削除する前に確認ダイアログを表示する