diff --git a/app/controllers/settings/preferences/other_controller.rb b/app/controllers/settings/preferences/other_controller.rb index a19fbf5c48..77b4fe10f8 100644 --- a/app/controllers/settings/preferences/other_controller.rb +++ b/app/controllers/settings/preferences/other_controller.rb @@ -1,6 +1,13 @@ # frozen_string_literal: true class Settings::Preferences::OtherController < Settings::Preferences::BaseController + include DtlHelper + + def show + @dtl_enabled = DTL_ENABLED + @dtl_tag = DTL_TAG + end + private def after_update_redirect_path diff --git a/app/helpers/dtl_helper.rb b/app/helpers/dtl_helper.rb new file mode 100644 index 0000000000..d3c3a8c662 --- /dev/null +++ b/app/helpers/dtl_helper.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +module DtlHelper + DTL_ENABLED = ENV.fetch('DTL_ENABLED', 'false') == 'true' + DTL_TAG = ENV.fetch('DTL_TAG', 'kmyblue') +end diff --git a/app/javascript/mastodon/features/ui/components/navigation_panel.jsx b/app/javascript/mastodon/features/ui/components/navigation_panel.jsx index 07e0980d21..5b412ba147 100644 --- a/app/javascript/mastodon/features/ui/components/navigation_panel.jsx +++ b/app/javascript/mastodon/features/ui/components/navigation_panel.jsx @@ -7,7 +7,7 @@ import { Link } from 'react-router-dom'; import { WordmarkLogo } from 'mastodon/components/logo'; import NavigationPortal from 'mastodon/components/navigation_portal'; -import { enableDtlMenu, timelinePreview, trendsEnabled } from 'mastodon/initial_state'; +import { enableDtlMenu, timelinePreview, trendsEnabled, dtlTag } from 'mastodon/initial_state'; import { transientSingleColumn } from 'mastodon/is_mobile'; import ColumnLink from './column_link'; @@ -93,8 +93,8 @@ class NavigationPanel extends Component { )} - {signedIn && enableDtlMenu && ( - + {signedIn && enableDtlMenu && dtlTag && ( + )} {!signedIn && explorer} diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index 356f7515b2..3e84866233 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -58,6 +58,7 @@ * @property {string} display_media * @property {boolean} display_media_expand * @property {string} domain + * @property {string} dtl_tag * @property {boolean} enable_login_privacy * @property {boolean} enable_dtl_menu * @property {boolean=} expand_spoilers @@ -124,6 +125,7 @@ export const disabledAccountId = getMeta('disabled_account_id'); export const displayMedia = getMeta('display_media'); export const displayMediaExpand = getMeta('display_media_expand'); export const domain = getMeta('domain'); +export const dtlTag = getMeta('dtl_tag'); export const enableLoginPrivacy = getMeta('enable_login_privacy'); export const enableDtlMenu = getMeta('enable_dtl_menu'); export const expandSpoilers = getMeta('expand_spoilers'); diff --git a/app/models/status.rb b/app/models/status.rb index 786daa142c..45e221d71c 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -43,6 +43,7 @@ class Status < ApplicationRecord include RateLimitable include StatusSafeReblogInsert include StatusSearchConcern + include DtlHelper rate_limit by: :account, family: :statuses @@ -291,7 +292,7 @@ class Status < ApplicationRecord end def dtl? - tags.where(name: 'kmyblue').exists? + tags.where(name: DTL_TAG).exists? end def emojis diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index edc6bfe713..45888d7572 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -2,6 +2,7 @@ class InitialStateSerializer < ActiveModel::Serializer include RoutingHelper + include DtlHelper attributes :meta, :compose, :accounts, :media_attachments, :settings, @@ -35,6 +36,7 @@ class InitialStateSerializer < ActiveModel::Serializer trends_as_landing_page: Setting.trends_as_landing_page, status_page_url: Setting.status_page_url, sso_redirect: sso_redirect, + dtl_tag: DTL_ENABLED ? DTL_TAG : nil, } if object.current_account diff --git a/app/services/delivery_antenna_service.rb b/app/services/delivery_antenna_service.rb index 5443c22bdb..e494321917 100644 --- a/app/services/delivery_antenna_service.rb +++ b/app/services/delivery_antenna_service.rb @@ -2,6 +2,7 @@ class DeliveryAntennaService include FormattingHelper + include DtlHelper def call(status, update, **options) @status = status @@ -23,6 +24,8 @@ class DeliveryAntennaService def delivery! must_dtl_tag = @account.dissubscribable + return if must_dtl_tag && !DTL_ENABLED + tag_ids = @status.tags.pluck(:id) domain = @account.domain || Rails.configuration.x.local_domain follower_ids = @status.unlisted_visibility? ? @status.account.followers.pluck(:id) : [] @@ -35,7 +38,7 @@ class DeliveryAntennaService antennas = Antenna.where(id: antennas.select(:id)) if must_dtl_tag - dtl_tag = Tag.find_or_create_by_names('kmyblue').first + dtl_tag = Tag.find_or_create_by_names(DTL_TAG).first return if !dtl_tag || tag_ids.exclude?(dtl_tag.id) antennas = antennas.left_joins(:antenna_tags).where(antenna_tags: { tag_id: dtl_tag.id }) diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index bec7249a62..a2e2653813 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -2,6 +2,7 @@ class FanOutOnWriteService < BaseService include Redisable + include DtlHelper # Push a status into home and mentions feeds # @param [Status] status @@ -51,7 +52,7 @@ class FanOutOnWriteService < BaseService when :public, :unlisted, :public_unlisted, :login, :private deliver_to_all_followers! deliver_to_lists! - deliver_to_antennas! if !@account.dissubscribable || (@status.dtl? && @account.user&.setting_dtl_force_subscribable && @status.tags.exists?(name: 'kmyblue')) + deliver_to_antennas! if !@account.dissubscribable || (@status.dtl? && DTL_ENABLED && @account.user&.setting_dtl_force_subscribable && @status.tags.exists?(name: DTL_TAG)) deliver_to_stl_antennas! deliver_to_ltl_antennas! when :limited diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index bd0e2a462a..2e5b765d86 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -3,6 +3,7 @@ class PostStatusService < BaseService include Redisable include LanguagesHelper + include DtlHelper MIN_SCHEDULE_OFFSET = 5.minutes.freeze @@ -101,8 +102,10 @@ class PostStatusService < BaseService end def overwrite_dtl_post + return unless DTL_ENABLED + raw_tags = Extractor.extract_hashtags(@text) - return if raw_tags.exclude?('kmyblue') + 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 diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index 55bf9c6dda..4ac6124041 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -42,18 +42,20 @@ .fields-group = ff.input :'web.enable_login_privacy', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_login_privacy'), hint: false - %h4= t 'preferences.dtl' + - if @dtl_enabled - %p.hint= t 'preferences.dtl_hint' + %h4= t 'preferences.dtl' - .fields-group - = ff.input :'web.enable_dtl_menu', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_dtl_menu'), hint: I18n.t('simple_form.hints.defaults.setting_dtl_menu') + %p.hint= t 'preferences.dtl_hint', tag: @dtl_tag - .fields-group - = ff.input :dtl_force_with_tag, kmyblue: true, collection: ['full', 'searchability', 'none'], label_method: lambda { |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') + .fields-group + = 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_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') + .fields-group + = ff.input :dtl_force_with_tag, kmyblue: true, collection: ['full', 'searchability', 'none'], label_method: lambda { |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) + + .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') %h4= t 'preferences.public_timelines' diff --git a/config/locales/en.yml b/config/locales/en.yml index 80d20c8061..b05633ad47 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1645,7 +1645,7 @@ en: too_many_options: can't contain more than %{max} items preferences: dtl: Deep timeline - dtl_hint: "You can join deep timeline with #kmyblue tag. Following settings make convenient to use deep timeline." + dtl_hint: "You can join deep timeline with #%{tag} tag. Following settings make convenient to use deep timeline." other: Other posting_defaults: Posting defaults public_timelines: Public timelines diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 52c8cb7b76..0b36b6dc42 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1585,7 +1585,7 @@ ja: too_many_options: は%{max}個までです preferences: dtl: ディープタイムライン - dtl_hint: "#kmyblue ハッシュタグに参加することで、ディープタイムラインに投稿できます。ここではディープタイムラインを利用しやすくするための設定ができます。" + dtl_hint: "#%{tag} ハッシュタグに参加することで、ディープタイムラインに投稿できます。ここではディープタイムラインを利用しやすくするための設定ができます。" other: その他 posting_defaults: デフォルトの投稿設定 public_timelines: 公開タイムライン diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 24d5981302..4a927ea211 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -67,7 +67,7 @@ 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 #kmyblue tag, your post settings will be changed forcibly" + setting_dtl_force_with_tag: "With using #%{tag} tag, your post settings will be changed forcibly" setting_dtl_menu: Show DTL menu on web setting_use_blurhash: Gradients are based on the colors of the hidden visuals but obfuscate any details setting_use_pending_items: Hide timeline updates behind a click instead of automatically scrolling the feed diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index ccda4fa8cf..699173a951 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -69,7 +69,7 @@ ja: setting_display_media_hide_all: メディアを常に隠す setting_display_media_show_all: メディアを常に表示する setting_dtl_force_subscribable: 購読拒否設定に関係なく、ディープタイムラインに向けた投稿はアンテナに掲載されます。ディープタイムラインをアンテナ経由で閲覧している人にあなたの発言が届きます - setting_dtl_force_with_tag: "ハッシュタグ #kmyblue をつけて投稿するとき、公開範囲と検索許可を強制的に置き換えるかを設定します" + setting_dtl_force_with_tag: "ハッシュタグ #%{tag} をつけて投稿するとき、公開範囲と検索許可を強制的に置き換えるかを設定します" setting_emoji_reaction_streaming_notify_impl2: 当該サーバーの独自機能に対応したアプリを利用時に、スタンプ機能を利用できます。動作確認していないため(そもそもそのようなアプリ自体を確認できていないため)正しく動かない場合があります setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします setting_link_preview: プレビュー生成を停止することは、センシティブなサイトへのリンクを頻繁に投稿する人にも有効かもしれません