Fix processing of mentions for post edits with an existing corresponding silent mention (#33227)

This commit is contained in:
Claire 2024-12-11 13:59:29 +01:00 committed by GitHub
parent da279df8ae
commit bcb3b627b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 21 deletions

View file

@ -13,7 +13,7 @@ class ProcessMentionsService < BaseService
return unless @status.local?
@previous_mentions = @status.active_mentions.includes(:account).to_a
@previous_mentions = @status.mentions.includes(:account).to_a
@current_mentions = []
Status.transaction do
@ -57,6 +57,8 @@ class ProcessMentionsService < BaseService
mention ||= @current_mentions.find { |x| x.account_id == mentioned_account.id }
mention ||= @status.mentions.new(account: mentioned_account)
mention.silent = false
@current_mentions << mention
"@#{mentioned_account.acct}"
@ -78,7 +80,7 @@ class ProcessMentionsService < BaseService
end
@current_mentions.each do |mention|
mention.save if mention.new_record? && @save_records
mention.save if (mention.new_record? || mention.silent_changed?) && @save_records
end
# If previous mentions are no longer contained in the text, convert them
@ -86,7 +88,7 @@ class ProcessMentionsService < BaseService
# received a notification might be more confusing
removed_mentions = @previous_mentions - @current_mentions
Mention.where(id: removed_mentions.map(&:id)).update_all(silent: true) unless removed_mentions.empty?
Mention.where(id: removed_mentions.map(&:id), silent: false).update_all(silent: true) unless removed_mentions.empty?
end
def mention_undeliverable?(mentioned_account)