From 0d717a873c8a4e3efeba0e1a46cf5784d1a86f15 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 6 Feb 2026 11:09:42 +0100 Subject: [PATCH] Fix processing of object updates with duplicate hashtags (#37756) --- app/services/activitypub/process_status_update_service.rb | 2 +- .../activitypub/process_status_update_service_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/activitypub/process_status_update_service.rb b/app/services/activitypub/process_status_update_service.rb index c45454fc7..2e87f850c 100644 --- a/app/services/activitypub/process_status_update_service.rb +++ b/app/services/activitypub/process_status_update_service.rb @@ -208,7 +208,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService Tag.find_or_create_by_names([tag]).filter(&:valid?) rescue ActiveRecord::RecordInvalid [] - end + end.uniq return unless @status.distributable? diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 9dc1ece33..e568c90f2 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -259,6 +259,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do { type: 'Hashtag', name: 'foo' }, { type: 'Hashtag', name: 'bar' }, { type: 'Hashtag', name: '#2024' }, + { type: 'Hashtag', name: 'Foo Bar' }, + { type: 'Hashtag', name: 'FooBar' }, ], } end @@ -270,7 +272,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do it 'updates tags and featured tags' do expect { subject.call(status, json, json) } - .to change { status.tags.reload.pluck(:name) }.from(contain_exactly('test', 'foo')).to(contain_exactly('foo', 'bar')) + .to change { status.tags.reload.pluck(:name) }.from(contain_exactly('test', 'foo')).to(contain_exactly('foo', 'bar', 'foobar')) .and change { status.account.featured_tags.find_by(name: 'test').statuses_count }.by(-1) .and change { status.account.featured_tags.find_by(name: 'bar').statuses_count }.by(1) .and change { status.account.featured_tags.find_by(name: 'bar').last_status_at }.from(nil).to(be_present)