Fix handling of duplicate mentions in incoming status Update (#33911)

This commit is contained in:
Claire 2025-02-12 16:34:56 +01:00 committed by GitHub
parent 6b52227fcc
commit 1248c4d1f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View File

@ -227,7 +227,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
nil
end
@status.mentions.upsert_all(currently_mentioned_account_ids.map { |id| { account_id: id, silent: false } }, unique_by: %w(status_id account_id))
@status.mentions.upsert_all(currently_mentioned_account_ids.uniq.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

View File

@ -37,10 +37,16 @@ RSpec.describe ActivityPub::Activity::Create do
content: '@bob lorem ipsum',
published: 1.hour.ago.utc.iso8601,
updated: 1.hour.ago.utc.iso8601,
tag: {
type: 'Mention',
href: ActivityPub::TagManager.instance.uri_for(follower),
},
tag: [
{
type: 'Mention',
href: ActivityPub::TagManager.instance.uri_for(follower),
},
{
type: 'Mention',
href: ActivityPub::TagManager.instance.uri_for(follower),
},
],
}
end

View File

@ -18,6 +18,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
tag: [
{ type: 'Hashtag', name: 'hoge' },
{ type: 'Mention', href: ActivityPub::TagManager.instance.uri_for(alice) },
{ type: 'Mention', href: ActivityPub::TagManager.instance.uri_for(alice) },
{ type: 'Mention', href: bogus_mention },
],
}