Make DTL switchable

This commit is contained in:
KMY 2023-09-12 09:04:20 +09:00
parent 65fe554773
commit 6fe51e360a
14 changed files with 46 additions and 19 deletions

View file

@ -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

View file

@ -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

View file

@ -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 && (
<ColumnLink transparent to='/tags/kmyblue' icon='users' text={intl.formatMessage(messages.deepLocal)} />
{signedIn && enableDtlMenu && dtlTag && (
<ColumnLink transparent to={`/tags/${dtlTag}`} icon='users' text={intl.formatMessage(messages.deepLocal)} />
)}
{!signedIn && explorer}

View file

@ -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');

View file

@ -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

View file

@ -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

View file

@ -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 })

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -1585,7 +1585,7 @@ ja:
too_many_options: は%{max}個までです
preferences:
dtl: ディープタイムライン
dtl_hint: "#kmyblue ハッシュタグに参加することで、ディープタイムラインに投稿できます。ここではディープタイムラインを利用しやすくするための設定ができます。"
dtl_hint: "#%{tag} ハッシュタグに参加することで、ディープタイムラインに投稿できます。ここではディープタイムラインを利用しやすくするための設定ができます。"
other: その他
posting_defaults: デフォルトの投稿設定
public_timelines: 公開タイムライン

View file

@ -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

View file

@ -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: プレビュー生成を停止することは、センシティブなサイトへのリンクを頻繁に投稿する人にも有効かもしれません