Add dtl settings
This commit is contained in:
parent
71f4eba500
commit
0a844ccdc7
12 changed files with 77 additions and 5 deletions
|
@ -107,6 +107,14 @@ module HasUserSettings
|
|||
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
|
||||
|
|
|
@ -290,6 +290,10 @@ class Status < ApplicationRecord
|
|||
@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)
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ class UserSettings
|
|||
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
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ class DeliveryAntennaService
|
|||
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) : []
|
||||
|
@ -28,9 +29,15 @@ class DeliveryAntennaService
|
|||
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?
|
||||
|
|
|
@ -51,7 +51,7 @@ class FanOutOnWriteService < BaseService
|
|||
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!
|
||||
|
|
|
@ -86,6 +86,7 @@ class PostStatusService < BaseService
|
|||
@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
|
||||
|
@ -99,6 +100,15 @@ class PostStatusService < BaseService
|
|||
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')
|
||||
|
||||
@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])
|
||||
|
@ -170,7 +180,7 @@ class PostStatusService < BaseService
|
|||
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, [])
|
||||
|
|
|
@ -42,6 +42,16 @@
|
|||
.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 :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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue