Add ltl mode support
This commit is contained in:
parent
7656687d43
commit
d1ae53e688
12 changed files with 188 additions and 27 deletions
|
@ -3,15 +3,19 @@
|
|||
class DeliveryAntennaService
|
||||
include FormattingHelper
|
||||
|
||||
def call(status, update, stl_home)
|
||||
def call(status, update, **options)
|
||||
@status = status
|
||||
@account = @status.account
|
||||
@update = update
|
||||
|
||||
if stl_home
|
||||
delivery_stl!
|
||||
else
|
||||
mode = options[:mode] || :home
|
||||
case mode
|
||||
when :home
|
||||
delivery!
|
||||
when :stl
|
||||
delivery_stl!
|
||||
when :ltl
|
||||
delivery_ltl!
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,7 +48,7 @@ class DeliveryAntennaService
|
|||
antennas = antennas.where(account: @status.mentioned_accounts) if @status.visibility.to_sym == :limited
|
||||
antennas = antennas.where(with_media_only: false) unless @status.with_media?
|
||||
antennas = antennas.where(ignore_reblog: false) if @status.reblog?
|
||||
antennas = antennas.where(stl: false)
|
||||
antennas = antennas.where(stl: false, ltl: false)
|
||||
|
||||
collection = AntennaCollection.new(@status, @update, false)
|
||||
content = extract_status_plain_text_with_spoiler_text(@status)
|
||||
|
@ -72,7 +76,7 @@ class DeliveryAntennaService
|
|||
antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
|
||||
|
||||
home_post = !@account.domain.nil? || @status.reblog? || [:public, :public_unlisted, :login].exclude?(@status.visibility.to_sym)
|
||||
antennas = antennas.where(account: @account.followers).or(antennas.where(account: @account)).where.not(list_id: 0) if home_post
|
||||
antennas = antennas.where(account: @account.followers).or(antennas.where(account: @account)).where('insert_feeds IS FALSE OR list_id > 0') if home_post
|
||||
|
||||
collection = AntennaCollection.new(@status, @update, home_post)
|
||||
|
||||
|
@ -87,6 +91,26 @@ class DeliveryAntennaService
|
|||
collection.deliver!
|
||||
end
|
||||
|
||||
def delivery_ltl!
|
||||
return if %i(public public_unlisted login).exclude?(@status.visibility.to_sym)
|
||||
return unless @account.local?
|
||||
|
||||
antennas = Antenna.available_ltls
|
||||
antennas = antennas.where(account_id: Account.without_suspended.joins(:user).select('accounts.id').where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago))
|
||||
|
||||
collection = AntennaCollection.new(@status, @update, false)
|
||||
|
||||
antennas.in_batches do |ans|
|
||||
ans.each do |antenna|
|
||||
next if antenna.expired?
|
||||
|
||||
collection.push(antenna)
|
||||
end
|
||||
end
|
||||
|
||||
collection.deliver!
|
||||
end
|
||||
|
||||
class AntennaCollection
|
||||
def initialize(status, update, stl_home = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
@status = status
|
||||
|
|
|
@ -53,6 +53,7 @@ class FanOutOnWriteService < BaseService
|
|||
deliver_to_lists!
|
||||
deliver_to_antennas! if !@account.dissubscribable || (@status.dtl? && @account.user&.setting_dtl_force_subscribable && @status.tags.exists?(name: 'kmyblue'))
|
||||
deliver_to_stl_antennas!
|
||||
deliver_to_ltl_antennas!
|
||||
when :limited
|
||||
deliver_to_lists_mentioned_accounts_only!
|
||||
deliver_to_antennas! unless @account.dissubscribable
|
||||
|
@ -135,11 +136,15 @@ class FanOutOnWriteService < BaseService
|
|||
end
|
||||
|
||||
def deliver_to_stl_antennas!
|
||||
DeliveryAntennaService.new.call(@status, @options[:update], true)
|
||||
DeliveryAntennaService.new.call(@status, @options[:update], mode: :stl)
|
||||
end
|
||||
|
||||
def deliver_to_ltl_antennas!
|
||||
DeliveryAntennaService.new.call(@status, @options[:update], mode: :ltl)
|
||||
end
|
||||
|
||||
def deliver_to_antennas!
|
||||
DeliveryAntennaService.new.call(@status, @options[:update], false)
|
||||
DeliveryAntennaService.new.call(@status, @options[:update], mode: :home)
|
||||
end
|
||||
|
||||
def deliver_to_mentioned_followers!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue