Add conversation-based forwarding for limited visibility statuses through bearcaps
This commit is contained in:
parent
52157fdcba
commit
7cd4ed7d42
26 changed files with 430 additions and 78 deletions
|
@ -52,6 +52,7 @@ class PostStatusService < BaseService
|
|||
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
|
||||
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
|
||||
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
|
||||
@visibility = :limited if @visibility&.to_sym != :direct && @in_reply_to&.limited_visibility?
|
||||
@scheduled_at = @options[:scheduled_at]&.to_datetime
|
||||
@scheduled_at = nil if scheduled_in_the_past?
|
||||
rescue ArgumentError
|
||||
|
@ -64,10 +65,11 @@ class PostStatusService < BaseService
|
|||
|
||||
ApplicationRecord.transaction do
|
||||
@status = @account.statuses.create!(status_attributes)
|
||||
@status.capability_tokens.create! if @status.limited_visibility?
|
||||
end
|
||||
|
||||
process_hashtags_service.call(@status)
|
||||
process_mentions_service.call(@status)
|
||||
ProcessHashtagsService.new.call(@status)
|
||||
ProcessMentionsService.new.call(@status)
|
||||
end
|
||||
|
||||
def schedule_status!
|
||||
|
@ -109,14 +111,6 @@ class PostStatusService < BaseService
|
|||
ISO_639.find(str)&.alpha2
|
||||
end
|
||||
|
||||
def process_mentions_service
|
||||
ProcessMentionsService.new
|
||||
end
|
||||
|
||||
def process_hashtags_service
|
||||
ProcessHashtagsService.new
|
||||
end
|
||||
|
||||
def scheduled?
|
||||
@scheduled_at.present?
|
||||
end
|
||||
|
|
|
@ -42,9 +42,21 @@ class ProcessMentionsService < BaseService
|
|||
"@#{mentioned_account.acct}"
|
||||
end
|
||||
|
||||
if status.limited_visibility? && status.thread&.limited_visibility?
|
||||
# If we are replying to a local status, then we'll have the complete
|
||||
# audience copied here, both local and remote. If we are replying
|
||||
# to a remote status, only local audience will be copied. Then we
|
||||
# need to send our reply to the remote author's inbox for distribution
|
||||
|
||||
status.thread.mentions.includes(:account).find_each do |mention|
|
||||
status.mentions.create(silent: true, account: mention.account)
|
||||
end
|
||||
end
|
||||
|
||||
status.save!
|
||||
check_for_spam(status)
|
||||
|
||||
# Silent mentions need to be delivered separately
|
||||
mentions.each { |mention| create_notification(mention) }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue