Skip to content

Commit

Permalink
Add: #559 公開投稿を禁止する管理者設定 (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode authored Feb 16, 2024
1 parent f1ce14e commit c534c3d
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/helpers/kmyblue_capabilities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/mastodon/features/about/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -232,6 +234,9 @@ class About extends PureComponent {
<li>
<span className='rules-list__text'>{intl.formatMessage(messages.emojiReaction)}: <CapabilityIcon state={isEmojiReaction} intl={intl} /></span>
</li>
<li>
<span className='rules-list__text'>{intl.formatMessage(messages.publicVisibility)}: <CapabilityIcon state={isPublicVisibility} intl={intl} /></span>
</li>
<li>
<span className='rules-list__text'>{intl.formatMessage(messages.publicUnlistedVisibility)}: <CapabilityIcon state={isPublicUnlistedVisibility} intl={intl} /></span>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down Expand Up @@ -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];
}

Expand Down
2 changes: 2 additions & 0 deletions app/javascript/mastodon/initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "アンテナから追加または外す",
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/serializers/initial_state_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions app/services/post_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/settings/discovery/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 に関する統計情報を収集するサービスによって使用されます。
Expand Down Expand Up @@ -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で公開する
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c534c3d

Please sign in to comment.