Merge remote-tracking branch 'parent/main' into upstream-20241216
This commit is contained in:
commit
3784ad273c
555 changed files with 7564 additions and 3363 deletions
|
@ -259,40 +259,30 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
end
|
||||
|
||||
def update_mentions!
|
||||
previous_mentions = @status.active_mentions.includes(:account).to_a
|
||||
current_mentions = []
|
||||
unresolved_mentions = []
|
||||
|
||||
@raw_mentions.each do |href|
|
||||
currently_mentioned_account_ids = @raw_mentions.filter_map do |href|
|
||||
next if href.blank?
|
||||
|
||||
account = ActivityPub::TagManager.instance.uri_to_resource(href, Account)
|
||||
account ||= ActivityPub::FetchRemoteAccountService.new.call(href, request_id: @request_id)
|
||||
|
||||
next if account.nil?
|
||||
|
||||
mention = previous_mentions.find { |x| x.account_id == account.id }
|
||||
mention ||= account.mentions.new(status: @status)
|
||||
|
||||
current_mentions << mention
|
||||
account&.id
|
||||
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS
|
||||
# Since previous mentions are about already-known accounts,
|
||||
# they don't try to resolve again and won't fall into this case.
|
||||
# In other words, this failure case is only for new mentions and won't
|
||||
# affect `removed_mentions` so they can safely be retried asynchronously
|
||||
unresolved_mentions << href
|
||||
nil
|
||||
end
|
||||
|
||||
current_mentions.each do |mention|
|
||||
mention.save if mention.new_record?
|
||||
end
|
||||
@status.mentions.upsert_all(currently_mentioned_account_ids.map { |id| { account_id: id, silent: false } }, unique_by: %w(status_id account_id))
|
||||
|
||||
# If previous mentions are no longer contained in the text, convert them
|
||||
# to silent mentions, since withdrawing access from someone who already
|
||||
# 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?
|
||||
@status.mentions.where.not(account_id: currently_mentioned_account_ids).update_all(silent: true)
|
||||
|
||||
# Queue unresolved mentions for later
|
||||
unresolved_mentions.uniq.each do |uri|
|
||||
|
|
|
@ -15,7 +15,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
|
||||
|
@ -63,6 +63,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}"
|
||||
|
@ -87,7 +89,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
|
||||
|
@ -95,7 +97,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)
|
||||
|
|
|
@ -20,7 +20,7 @@ class SuspendAccountService < BaseService
|
|||
private
|
||||
|
||||
def reject_remote_follows!
|
||||
return if @account.local? || !@account.activitypub?
|
||||
return if @account.local? || !@account.activitypub? || @account.suspension_origin_remote?
|
||||
|
||||
# When suspending a remote account, the account obviously doesn't
|
||||
# actually become suspended on its origin server, i.e. unlike a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue