Skip to content

Commit

Permalink
Merge branch 'kb_development' into kb_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Sep 10, 2023
2 parents 4bc813e + 9aa4561 commit e9de561
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Link } from 'react-router-dom';

import { WordmarkLogo } from 'mastodon/components/logo';
import NavigationPortal from 'mastodon/components/navigation_portal';
import { timelinePreview, trendsEnabled } from 'mastodon/initial_state';
import { enableDtlMenu, timelinePreview, trendsEnabled } from 'mastodon/initial_state';
import { transientSingleColumn } from 'mastodon/is_mobile';

import ColumnLink from './column_link';
Expand All @@ -22,6 +22,7 @@ const messages = defineMessages({
notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
explore: { id: 'explore.title', defaultMessage: 'Explore' },
local: { id: 'column.local', defaultMessage: 'Local' },
deepLocal: { id: 'column.deep_local', defaultMessage: 'Deep' },
firehose: { id: 'column.firehose', defaultMessage: 'Live feeds' },
direct: { id: 'navigation_bar.direct', defaultMessage: 'Private mentions' },
favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favorites' },
Expand Down Expand Up @@ -92,6 +93,10 @@ class NavigationPanel extends Component {
</>
)}

{signedIn && enableDtlMenu && (
<ColumnLink transparent to='/tags/kmyblue' icon='users' text={intl.formatMessage(messages.deepLocal)} />
)}

{!signedIn && explorer}

{signedIn && (
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 @@ -59,6 +59,7 @@
* @property {boolean} display_media_expand
* @property {string} domain
* @property {boolean} enable_login_privacy
* @property {boolean} enable_dtl_menu
* @property {boolean=} expand_spoilers
* @property {boolean} hide_recent_emojis
* @property {boolean} limited_federation_mode
Expand Down Expand Up @@ -124,6 +125,7 @@ export const displayMedia = getMeta('display_media');
export const displayMediaExpand = getMeta('display_media_expand');
export const domain = getMeta('domain');
export const enableLoginPrivacy = getMeta('enable_login_privacy');
export const enableDtlMenu = getMeta('enable_dtl_menu');
export const expandSpoilers = getMeta('expand_spoilers');
export const forceSingleColumn = !getMeta('advanced_layout');
export const hideRecentEmojis = getMeta('hide_recent_emojis');
Expand Down
12 changes: 12 additions & 0 deletions app/models/concerns/has_user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def setting_enable_login_privacy
settings['web.enable_login_privacy']
end

def setting_enable_dtl_menu
settings['web.enable_dtl_menu']
end

def setting_bookmark_category_needed
settings['web.bookmark_category_needed']
end
Expand Down Expand Up @@ -107,6 +111,14 @@ def setting_link_preview
settings['link_preview']
end

def setting_dtl_force_with_tag
settings['dtl_force_with_tag']&.to_sym || :none
end

def setting_dtl_force_subscribable
settings['dtl_force_subscribable']
end

def setting_hide_statuses_count
settings['hide_statuses_count']
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/emoji_reaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class EmojiReaction < ApplicationRecord
after_destroy :refresh_cache
after_destroy :invalidate_cleanup_info

def custom_emoji?
custom_emoji.present?
end

def remote_custom_emoji?
custom_emoji? && !custom_emoji.local?
end

private

def refresh_cache
Expand Down
4 changes: 4 additions & 0 deletions app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def reported?
@reported ||= Report.where(target_account: account).unresolved.where('? = ANY(status_ids)', id).exists?
end

def dtl?
tags.where(name: 'kmyblue').exists?
end

def emojis
return @emojis if defined?(@emojis)

Expand Down
3 changes: 3 additions & 0 deletions app/models/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class KeyError < Error; end
setting :stop_emoji_reaction_streaming, default: false
setting :emoji_reaction_streaming_notify_impl2, default: false
setting :unsafe_limited_distribution, default: false
setting :dtl_force_with_tag, default: :none, in: %w(full searchability none)
setting :dtl_force_subscribable, default: false

setting_inverse_alias :indexable, :noindex

Expand All @@ -48,6 +50,7 @@ class KeyError < Error; end
setting :disable_swiping, default: false
setting :delete_modal, default: true
setting :enable_login_privacy, default: false
setting :enable_dtl_menu, default: false
setting :hide_recent_emojis, default: false
setting :reblog_modal, default: false
setting :unfollow_modal, default: true
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 @@ -47,6 +47,7 @@ def meta
store[:display_media_expand] = object.current_account.user.setting_display_media_expand
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
store[:enable_login_privacy] = object.current_account.user.setting_enable_login_privacy
store[:enable_dtl_menu] = object.current_account.user.setting_enable_dtl_menu
store[:hide_recent_emojis] = object.current_account.user.setting_hide_recent_emojis
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
store[:disable_swiping] = object.current_account.user.setting_disable_swiping
Expand Down
11 changes: 9 additions & 2 deletions app/services/delivery_antenna_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def call(status, update, stl_home)
private

def delivery!
must_dtl_tag = @account.dissubscribable
tag_ids = @status.tags.pluck(:id)
domain = @account.domain || Rails.configuration.x.local_domain
follower_ids = @status.unlisted_visibility? ? @status.account.followers.pluck(:id) : []
Expand All @@ -28,9 +29,15 @@ def delivery!
antennas = Antenna.where(id: antennas.select(:id))
antennas = antennas.left_joins(:antenna_accounts).where(any_accounts: true).or(Antenna.left_joins(:antenna_accounts).where(antenna_accounts: { account: @account }))

tag_ids = @status.tags.pluck(:id)
antennas = Antenna.where(id: antennas.select(:id))
antennas = antennas.left_joins(:antenna_tags).where(any_tags: true).or(Antenna.left_joins(:antenna_tags).where(antenna_tags: { tag_id: tag_ids }))
if must_dtl_tag
dtl_tag = Tag.find_or_create_by_names('kmyblue').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 })
else
antennas = antennas.left_joins(:antenna_tags).where(any_tags: true).or(Antenna.left_joins(:antenna_tags).where(antenna_tags: { tag_id: tag_ids }))
end

antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
antennas = antennas.where(account: @status.account.followers) if [:public, :public_unlisted, :login, :limited].exclude?(@status.visibility.to_sym) && !@status.public_searchability?
Expand Down
1 change: 1 addition & 0 deletions app/services/emoji_react_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def notify_to_followers(emoji_reaction)
status = emoji_reaction.status

return unless status.account.local?
return if emoji_reaction.remote_custom_emoji?

ActivityPub::RawDistributionWorker.perform_async(build_json(emoji_reaction), status.account_id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/fan_out_on_write_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fan_out_to_local_recipients!
when :public, :unlisted, :public_unlisted, :login, :private
deliver_to_all_followers!
deliver_to_lists!
deliver_to_antennas! unless @account.dissubscribable
deliver_to_antennas! if !@account.dissubscribable || (@status.dtl? && @account.user&.setting_dtl_force_subscribable && @status.tags.exists?(name: 'kmyblue'))
deliver_to_stl_antennas!
when :limited
deliver_to_lists_mentioned_accounts_only!
Expand Down
15 changes: 13 additions & 2 deletions app/services/post_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def preprocess_attributes!
@options[:sensitive]
end) || @options[:spoiler_text].present?
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
@visibility = @options[:visibility]&.to_sym || @account.user&.setting_default_privacy&.to_sym
@visibility = :direct if @in_reply_to&.limited_visibility?
@visibility = :limited if %w(mutual circle).include?(@options[:visibility])
@visibility = :unlisted if (@visibility&.to_sym == :public || @visibility&.to_sym == :public_unlisted || @visibility&.to_sym == :login) && @account.silenced?
Expand All @@ -86,6 +86,7 @@ def preprocess_attributes!
@scheduled_at = nil if scheduled_in_the_past?
@reference_ids = (@options[:status_reference_ids] || []).map(&:to_i).filter(&:positive?)
load_circle
overwrite_dtl_post
process_sensitive_words
rescue ArgumentError
raise ActiveRecord::RecordInvalid
Expand All @@ -99,6 +100,16 @@ def load_circle
raise ArgumentError if @circle.nil? || @circle.account_id != @account.id
end

def overwrite_dtl_post
raw_tags = Extractor.extract_hashtags(@text)
return if raw_tags.exclude?('kmyblue')
return unless %i(public public_unlisted unlisted).include?(@visibility)

@visibility = :unlisted if @account.user&.setting_dtl_force_with_tag == :full
@searchability = :public if %i(full searchability).include?(@account.user&.setting_dtl_force_with_tag)
@dtl = true
end

def process_sensitive_words
if [:public, :public_unlisted, :login].include?(@visibility&.to_sym) && Admin::SensitiveWord.sensitive?(@text, @options[:spoiler_text] || '')
@text = Admin::SensitiveWord.modified_text(@text, @options[:spoiler_text])
Expand Down Expand Up @@ -170,7 +181,7 @@ def schedule_status!
end

def postprocess_status!
@account.user.update!(settings_attributes: { default_privacy: @options[:visibility] }) if @account.user&.setting_stay_privacy && !@status.reply? && %i(public public_unlisted login unlisted private).include?(@status.visibility.to_sym) && @status.visibility.to_s != @account.user&.setting_default_privacy
@account.user.update!(settings_attributes: { default_privacy: @options[:visibility] }) if @account.user&.setting_stay_privacy && !@status.reply? && %i(public public_unlisted login unlisted private).include?(@status.visibility.to_sym) && @status.visibility.to_s != @account.user&.setting_default_privacy && !@dtl

process_hashtags_service.call(@status)
ProcessReferencesWorker.perform_async(@status.id, @reference_ids, [])
Expand Down
13 changes: 13 additions & 0 deletions app/views/settings/preferences/other/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@
.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'

%p.hint= t 'preferences.dtl_hint'

.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')

.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 :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'

.fields-group
Expand Down
13 changes: 12 additions & 1 deletion config/initializers/simple_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ def warning_hint(_wrapper_options = nil)

config.wrappers :with_floating_label, class: [:input, :with_floating_label], hint_class: :field_with_hint, error_class: :field_with_errors do |b|
b.use :html5
b.use :label_input, wrap_with: { tag: :div, class: :label_input }

b.wrapper tag: :div, class: :label_input do |ba|
ba.optional :recommended
ba.optional :kmyblue
ba.use :label

ba.wrapper tag: :div, class: :label_input__wrapper do |bb|
bb.use :input
bb.optional :append, wrap_with: { tag: :div, class: 'label_input__append' }
end
end

b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
end
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,8 @@ en:
too_few_options: must have more than one item
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."
other: Other
posting_defaults: Posting defaults
public_timelines: Public timelines
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,8 @@ ja:
too_few_options: は複数必要です
too_many_options: は%{max}個までです
preferences:
dtl: ディープタイムライン
dtl_hint: "#kmyblue ハッシュタグに参加することで、ディープタイムラインに投稿できます。ここではディープタイムラインを利用しやすくするための設定ができます。"
other: その他
posting_defaults: デフォルトの投稿設定
public_timelines: 公開タイムライン
Expand Down
9 changes: 9 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ en:
setting_display_media_default: Hide media marked as sensitive
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_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
username: You can use letters, numbers, and underscores
Expand Down Expand Up @@ -234,6 +237,8 @@ en:
setting_display_media_expand: Show more medias
setting_display_media_hide_all: Hide all
setting_display_media_show_all: Show all
setting_dtl_force_subscribable: Ignore your dissubscribable setting when using the DTL tag
setting_dtl_force_with_tag: Post with DTL tag
setting_emoji_reaction_streaming_notify_impl2: Enable stamp notification compat with Nyastodon, Catstodon, glitch-soc
setting_enable_login_privacy: Enable login visibility
setting_expand_spoilers: Always expand posts marked with content warnings
Expand Down Expand Up @@ -267,6 +272,10 @@ en:
username: Username
username_or_email: Username or Email
whole_word: Whole word
dtl_force_with_tag:
full: Visibility is unlisted, searchability is public
none: No changes
searchability: Searchability is public
email_domain_block:
with_dns_records: Include MX records and IPs of the domain
emoji_reactions:
Expand Down
9 changes: 9 additions & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ ja:
setting_display_media_expand: Misskeyなどは4個を超えて投稿可能です。その追加分を最大16個まで表示します。kmyblueからアップロードはできません
setting_display_media_hide_all: メディアを常に隠す
setting_display_media_show_all: メディアを常に表示する
setting_dtl_force_subscribable: 購読拒否設定に関係なく、ディープタイムラインに向けた投稿はアンテナに掲載されます。ディープタイムラインをアンテナ経由で閲覧している人にあなたの発言が届きます
setting_dtl_force_with_tag: "ハッシュタグ #kmyblue をつけて投稿するとき、公開範囲と検索許可を強制的に置き換えるかを設定します"
setting_emoji_reaction_streaming_notify_impl2: 当該サーバーの独自機能に対応したアプリを利用時に、スタンプ機能を利用できます。動作確認していないため(そもそもそのようなアプリ自体を確認できていないため)正しく動かない場合があります
setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします
setting_link_preview: プレビュー生成を停止することは、センシティブなサイトへのリンクを頻繁に投稿する人にも有効かもしれません
Expand Down Expand Up @@ -244,6 +246,9 @@ ja:
setting_display_media_expand: 5個目以降のメディアも表示する (最大16)
setting_display_media_hide_all: 非表示
setting_display_media_show_all: 表示
setting_dtl_force_subscribable: ディープタイムライン用のハッシュタグを購読するアンテナに限り、購読拒否設定を無視する
setting_dtl_force_with_tag: DTL参加時の投稿設定
setting_dtl_menu: Webクライアントのメニューにディープタイムラインを追加する
setting_enable_login_privacy: 公開範囲「ログインユーザーのみ」をWeb UIで選択可能にする
setting_emoji_reaction_streaming_notify_impl2: Nyastodon, Catstodon, glitch-soc互換のスタンプ機能を有効にする
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
Expand Down Expand Up @@ -278,6 +283,10 @@ ja:
username: ユーザー名
username_or_email: ユーザー名またはメールアドレス
whole_word: 単語全体にマッチ
dtl_force_with_tag:
full: 公開範囲「未収載」検索許可「全て」にする
none: 公開範囲も検索許可も変更しない
searchability: 検索許可を「全て」にする
email_domain_block:
with_dns_records: ドメインのMXレコードとIPアドレスを含む
emoji_reactions:
Expand Down

0 comments on commit e9de561

Please sign in to comment.