mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Refactor ProcessMentionsService to remove save_records parameter (#38277)
This commit is contained in:
@@ -77,7 +77,7 @@ class PostStatusService < BaseService
|
||||
|
||||
def process_status!
|
||||
@status = @account.statuses.new(status_attributes)
|
||||
process_mentions_service.call(@status, save_records: false)
|
||||
process_mentions_service.call(@status)
|
||||
safeguard_mentions!(@status)
|
||||
safeguard_private_mention_quote!(@status)
|
||||
attach_quote!(@status)
|
||||
|
||||
@@ -6,10 +6,8 @@ class ProcessMentionsService < BaseService
|
||||
# Scan status for mentions and fetch remote mentioned users,
|
||||
# and create local mention pointers
|
||||
# @param [Status] status
|
||||
# @param [Boolean] save_records Whether to save records in database
|
||||
def call(status, save_records: true)
|
||||
def call(status)
|
||||
@status = status
|
||||
@save_records = save_records
|
||||
|
||||
return unless @status.local?
|
||||
|
||||
@@ -64,7 +62,7 @@ class ProcessMentionsService < BaseService
|
||||
"@#{mentioned_account.acct}"
|
||||
end
|
||||
|
||||
@status.save! if @save_records
|
||||
@status.save! if @status.persisted?
|
||||
end
|
||||
|
||||
def assign_mentions!
|
||||
@@ -79,8 +77,10 @@ class ProcessMentionsService < BaseService
|
||||
dropped_mentions.each(&:destroy)
|
||||
end
|
||||
|
||||
return unless @status.persisted?
|
||||
|
||||
@current_mentions.each do |mention|
|
||||
mention.save if (mention.new_record? || mention.silent_changed?) && @save_records
|
||||
mention.save if mention.new_record? || mention.silent_changed?
|
||||
end
|
||||
|
||||
# If previous mentions are no longer contained in the text, convert them
|
||||
|
||||
Reference in New Issue
Block a user