mirror of https://github.com/mastodon/mastodon
Fix handling of duplicate mentions in incoming status `Update` (#33911)
This commit is contained in:
parent
679e7555ee
commit
08d2250ad2
|
@ -225,7 +225,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
nil
|
nil
|
||||||
end
|
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
|
# If previous mentions are no longer contained in the text, convert them
|
||||||
# to silent mentions, since withdrawing access from someone who already
|
# to silent mentions, since withdrawing access from someone who already
|
||||||
|
|
|
@ -37,10 +37,16 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
content: '@bob lorem ipsum',
|
content: '@bob lorem ipsum',
|
||||||
published: 1.hour.ago.utc.iso8601,
|
published: 1.hour.ago.utc.iso8601,
|
||||||
updated: 1.hour.ago.utc.iso8601,
|
updated: 1.hour.ago.utc.iso8601,
|
||||||
tag: {
|
tag: [
|
||||||
type: 'Mention',
|
{
|
||||||
href: ActivityPub::TagManager.instance.uri_for(follower),
|
type: 'Mention',
|
||||||
},
|
href: ActivityPub::TagManager.instance.uri_for(follower),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'Mention',
|
||||||
|
href: ActivityPub::TagManager.instance.uri_for(follower),
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||||
tag: [
|
tag: [
|
||||||
{ type: 'Hashtag', name: 'hoge' },
|
{ 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: ActivityPub::TagManager.instance.uri_for(alice) },
|
||||||
{ type: 'Mention', href: bogus_mention },
|
{ type: 'Mention', href: bogus_mention },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue