From c534c3d7fe7416c0de08ae5548f6a7eea44ae4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Fri, 16 Feb 2024 18:43:43 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20#559=20=E5=85=AC=E9=96=8B=E6=8A=95?= =?UTF-8?q?=E7=A8=BF=E3=82=92=E7=A6=81=E6=AD=A2=E3=81=99=E3=82=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=80=85=E8=A8=AD=E5=AE=9A=20(#564)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/kmyblue_capabilities_helper.rb | 1 + app/javascript/mastodon/features/about/index.jsx | 5 +++++ .../features/compose/components/privacy_dropdown.jsx | 6 +++++- app/javascript/mastodon/initial_state.js | 2 ++ app/javascript/mastodon/locales/ja.json | 1 + app/javascript/mastodon/reducers/compose.js | 4 ++-- app/models/form/admin_settings.rb | 2 ++ app/models/status.rb | 1 + app/serializers/initial_state_serializer.rb | 1 + app/services/post_status_service.rb | 1 + app/views/admin/settings/discovery/show.html.haml | 3 +++ config/locales/simple_form.en.yml | 2 ++ config/locales/simple_form.ja.yml | 2 ++ config/settings.yml | 1 + 14 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/helpers/kmyblue_capabilities_helper.rb b/app/helpers/kmyblue_capabilities_helper.rb index ef6799faebe753..4cbcd9b2598541 100644 --- a/app/helpers/kmyblue_capabilities_helper.rb +++ b/app/helpers/kmyblue_capabilities_helper.rb @@ -28,6 +28,7 @@ def fedibird_capabilities end capabilities << :kmyblue_visibility_public_unlisted if Setting.enable_public_unlisted_visibility capabilities << :kmyblue_searchability_public_unlisted if Setting.enable_public_unlisted_visibility + capabilities << :kmyblue_no_public_visibility unless Setting.enable_public_visibility capabilities << :timeline_no_local unless Setting.enable_local_timeline capabilities diff --git a/app/javascript/mastodon/features/about/index.jsx b/app/javascript/mastodon/features/about/index.jsx index ffc693e7ecb14e..e111b026e1c87c 100644 --- a/app/javascript/mastodon/features/about/index.jsx +++ b/app/javascript/mastodon/features/about/index.jsx @@ -35,6 +35,7 @@ const messages = defineMessages({ suspended: { id: 'about.domain_blocks.suspended.title', defaultMessage: 'Suspended' }, suspendedExplanation: { id: 'about.domain_blocks.suspended.explanation', defaultMessage: 'No data from this server will be processed, stored or exchanged, making any interaction or communication with users from this server impossible.' }, publicUnlistedVisibility: { id: 'privacy.public_unlisted.short', defaultMessage: 'Public unlisted' }, + publicVisibility: { id: 'about.public_visibility', defaultMessage: 'Public visibility' }, emojiReaction: { id: 'status.emoji_reaction', defaultMessage: 'Emoji reaction' }, enabled: { id: 'about.enabled', defaultMessage: 'Enabled' }, disabled: { id: 'about.disabled', defaultMessage: 'Disabled' }, @@ -157,6 +158,7 @@ class About extends PureComponent { const fedibirdCapabilities = server.get('fedibird_capabilities') || []; // thinking about isLoading is true const isPublicUnlistedVisibility = fedibirdCapabilities.includes('kmyblue_visibility_public_unlisted'); + const isPublicVisibility = !fedibirdCapabilities.includes('kmyblue_no_public_visibility'); const isEmojiReaction = fedibirdCapabilities.includes('emoji_reaction'); const isLocalTimeline = !fedibirdCapabilities.includes('timeline_no_local'); @@ -232,6 +234,9 @@ class About extends PureComponent {
  • {intl.formatMessage(messages.emojiReaction)}:
  • +
  • + {intl.formatMessage(messages.publicVisibility)}: +
  • {intl.formatMessage(messages.publicUnlistedVisibility)}:
  • diff --git a/app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx b/app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx index 97e1e921edf88d..15d35835f22cbc 100644 --- a/app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx +++ b/app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx @@ -20,7 +20,7 @@ import QuietTimeIcon from '@/material-icons/400-24px/quiet_time.svg?react'; import ReplyIcon from '@/material-icons/400-24px/reply.svg?react'; import LimitedIcon from '@/material-icons/400-24px/shield.svg?react'; import { Icon } from 'mastodon/components/icon'; -import { enableLoginPrivacy, enableLocalPrivacy } from 'mastodon/initial_state'; +import { enableLoginPrivacy, enableLocalPrivacy, enablePublicPrivacy } from 'mastodon/initial_state'; const messages = defineMessages({ public_short: { id: 'privacy.public.short', defaultMessage: 'Public' }, @@ -279,6 +279,10 @@ class PrivacyDropdown extends PureComponent { this.options = this.options.filter((opt) => opt.value !== 'public_unlisted'); } + if (!enablePublicPrivacy) { + this.options = this.options.filter((opt) => opt.value !== 'public'); + } + this.selectableOptions = [...this.options]; } diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index b2c02ae5d89a6f..7f9a0cdf0e8e9c 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -38,6 +38,7 @@ * @property {boolean} enable_local_privacy * @property {boolean} enable_local_timeline * @property {boolean} enable_dtl_menu + * @property {boolean} enable_public_privacy * @property {boolean=} expand_spoilers * @property {HideItemsDefinition[]} hide_items * @property {boolean} limited_federation_mode @@ -122,6 +123,7 @@ export const domain = getMeta('domain'); export const dtlTag = getMeta('dtl_tag'); export const enableEmojiReaction = getMeta('enable_emoji_reaction'); export const enableLocalPrivacy = getMeta('enable_local_privacy'); +export const enablePublicPrivacy = getMeta('enable_public_privacy'); export const enableLocalTimeline = getMeta('enable_local_timeline'); export const enableLoginPrivacy = getMeta('enable_login_privacy'); export const enableDtlMenu = getMeta('enable_dtl_menu'); diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json index 59fc559491eeeb..acb40a4291a84a 100644 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@ -16,6 +16,7 @@ "about.kmyblue_capability": "このサーバーは、kmyblueというMastodonフォークを利用しています。kmyblue独自機能の一部は、サーバー管理者によって有効・無効を切り替えることができます。", "about.not_available": "この情報はこのサーバーでは利用できません。", "about.powered_by": "{mastodon}による分散型ソーシャルメディア", + "about.public_visibility": "公開投稿を許可", "about.rules": "サーバーのルール", "account.account_note_header": "メモ", "account.add_or_remove_from_antenna": "アンテナから追加または外す", diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 9fc59dd7ff371a..b757396bf30ec5 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -56,7 +56,7 @@ import { import { REDRAFT } from '../actions/statuses'; import { STORE_HYDRATE } from '../actions/store'; import { TIMELINE_DELETE } from '../actions/timelines'; -import { enableLocalPrivacy, enableLoginPrivacy, me } from '../initial_state'; +import { enableLocalPrivacy, enableLoginPrivacy, enablePublicPrivacy, me } from '../initial_state'; import { unescapeHTML } from '../utils/html'; import { uuid } from '../uuid'; @@ -142,7 +142,7 @@ function clearAll(state) { map.set('default_privacy', state.get('privacy')); } if ((map.get('privacy') === 'login' && !enableLoginPrivacy) || (map.get('privacy') === 'public_unlisted' && !enableLocalPrivacy)) { - map.set('privacy', 'public'); + map.set('privacy', enablePublicPrivacy ? 'public' : 'unlisted'); } if (!state.get('in_reply_to')) { map.set('posted_on_this_session', true); diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index fd694a887e4b7f..3cb864ace58cb4 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -57,6 +57,7 @@ class Form::AdminSettings streaming_local_emoji_reaction enable_emoji_reaction check_lts_version_only + enable_public_visibility enable_public_unlisted_visibility unlocked_friend enable_local_timeline @@ -95,6 +96,7 @@ class Form::AdminSettings streaming_local_emoji_reaction enable_emoji_reaction check_lts_version_only + enable_public_visibility enable_public_unlisted_visibility unlocked_friend stranger_mention_from_local_ng diff --git a/app/models/status.rb b/app/models/status.rb index d54517ead1fa58..9fa6860981849e 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -496,6 +496,7 @@ class << self def selectable_visibilities vs = visibilities.keys - %w(direct limited) vs -= %w(public_unlisted) unless Setting.enable_public_unlisted_visibility + vs -= %w(public) unless Setting.enable_public_visibility vs end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index c59d4235ba82c5..39a323900c028a 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -118,6 +118,7 @@ def default_meta_store domain: Addressable::IDNA.to_unicode(instance_presenter.domain), dtl_tag: dtl_enabled? ? dtl_tag_name : nil, enable_local_privacy: Setting.enable_public_unlisted_visibility, + enable_public_privacy: Setting.enable_public_visibility, enable_local_timeline: Setting.enable_local_timeline, limited_federation_mode: Rails.configuration.x.limited_federation_mode, locale: I18n.locale, diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 6776d08db6744f..1f9f1c05928caf 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -74,6 +74,7 @@ def preprocess_attributes! @visibility = :limited if %w(mutual circle reply).include?(@options[:visibility]) @visibility = :unlisted if (@visibility == :public || @visibility == :public_unlisted || @visibility == :login) && @account.silenced? @visibility = :public_unlisted if @visibility == :public && !@options[:force_visibility] && !@options[:application]&.superapp && @account.user&.setting_public_post_to_unlisted && Setting.enable_public_unlisted_visibility + @visibility = Setting.enable_public_unlisted_visibility ? :public_unlisted : :unlisted unless Setting.enable_public_visibility @limited_scope = @options[:visibility]&.to_sym if @visibility == :limited && @options[:visibility] != 'limited' @searchability = searchability @searchability = :private if @account.silenced? && %i(public public_unlisted).include?(@searchability&.to_sym) diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml index c4d0fd33544fab..88b5663a0d5161 100644 --- a/app/views/admin/settings/discovery/show.html.haml +++ b/app/views/admin/settings/discovery/show.html.haml @@ -45,6 +45,9 @@ %h4= t('admin.settings.discovery.visibilities') + .fields-group + = f.input :enable_public_visibility, as: :boolean, wrapper: :with_label, kmyblue: true + .fields-group = f.input :enable_public_unlisted_visibility, as: :boolean, wrapper: :with_label, kmyblue: true diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 8737b97d77aeab..b84893083ca322 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -101,6 +101,7 @@ en: custom_css: You can apply custom styles on the web version of Mastodon. enable_local_timeline: While enabling this feature will allow for interaction between like-minded users, it may also strengthen the internal atmosphere; since Mastodon is supposed to have a local timeline, we recommend annotating it in the server introduction if it is to be disabled. enable_public_unlisted_visibility: If true, your community maybe closed-minded. If turn it false, strongly recommend that you disclose that you have disabled this setting! + enable_public_visibility: If disabled, public submissions will be forcibly replaced with "Public unlisted" or "Unlisted" submissions. mascot: Overrides the illustration in the advanced web interface. media_cache_retention_period: Downloaded media files will be deleted after the specified number of days when set to a positive value, and re-downloaded on demand. peers_api_enabled: A list of domain names this server has encountered in the fediverse. No data is included here about whether you federate with a given server, just that your server knows about it. This is used by services that collect statistics on federation in a general sense. @@ -349,6 +350,7 @@ en: enable_emoji_reaction: Enable emoji reaction function enable_local_timeline: Enable local timeline enable_public_unlisted_visibility: Enable public-unlisted visibility / public-unlisted searchability + enable_public_visibility: Enable public visibility mascot: Custom mascot (legacy) media_cache_retention_period: Media cache retention period peers_api_enabled: Publish list of discovered servers in the API diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index e6fc7154934eac..8ff95d05fc3add 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -112,6 +112,7 @@ ja: custom_css: ウェブ版のMastodonでカスタムスタイルを適用できます。 enable_local_timeline: 有効にすると気の合ったユーザー同士の交流が捗る反面、内輪の雰囲気が強くなるかもしれません。Mastodonはローカルタイムラインがあるものだと思われているので、無効にする場合はサーバー紹介での注記をおすすめします。 enable_public_unlisted_visibility: 有効にするとあなたのコミュニティは閉鎖的になるかもしれません。この設定はkmyblueの主要機能の1つであり、無効にする場合は概要などに記載することを強くおすすめします。 + enable_public_visibility: 無効にすると公開投稿は強制的に「ローカル公開」または「非収載」に置き換えられます。 mascot: 上級者向けWebインターフェースのイラストを上書きします。 media_cache_retention_period: 正の値に設定されている場合、ダウンロードされたメディアファイルは指定された日数の後に削除され、リクエストに応じて再ダウンロードされます。 peers_api_enabled: このサーバーが Fediverse で遭遇したドメイン名のリストです。このサーバーが知っているだけで、特定のサーバーと連合しているかのデータは含まれません。これは一般的に Fediverse に関する統計情報を収集するサービスによって使用されます。 @@ -362,6 +363,7 @@ ja: enable_emoji_reaction: 絵文字リアクション機能を有効にする enable_local_timeline: ローカルタイムラインを有効にする enable_public_unlisted_visibility: 公開範囲「ローカル公開」と検索許可「ローカルとフォロワー」を有効にする + enable_public_visibility: 公開範囲「公開」を有効にする mascot: カスタムマスコット(レガシー) media_cache_retention_period: メディアキャッシュの保持期間 peers_api_enabled: 発見したサーバーのリストをAPIで公開する diff --git a/config/settings.yml b/config/settings.yml index f4ed5dc6952c1e..21b7839a4d880c 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -50,6 +50,7 @@ defaults: &defaults streaming_local_emoji_reaction: true enable_emoji_reaction: true check_lts_version_only: true + enable_public_visibility: true enable_public_unlisted_visibility: true unlocked_friend: false stranger_mention_from_local_ng: true