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

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