Fix processing of object updates with duplicate hashtags (#37756)
This commit is contained in:
@@ -208,7 +208,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||||||
Tag.find_or_create_by_names([tag]).filter(&:valid?)
|
Tag.find_or_create_by_names([tag]).filter(&:valid?)
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
[]
|
[]
|
||||||
end
|
end.uniq
|
||||||
|
|
||||||
return unless @status.distributable?
|
return unless @status.distributable?
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||||||
{ type: 'Hashtag', name: 'foo' },
|
{ type: 'Hashtag', name: 'foo' },
|
||||||
{ type: 'Hashtag', name: 'bar' },
|
{ type: 'Hashtag', name: 'bar' },
|
||||||
{ type: 'Hashtag', name: '#2024' },
|
{ type: 'Hashtag', name: '#2024' },
|
||||||
|
{ type: 'Hashtag', name: 'Foo Bar' },
|
||||||
|
{ type: 'Hashtag', name: 'FooBar' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -270,7 +272,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
|||||||
|
|
||||||
it 'updates tags and featured tags' do
|
it 'updates tags and featured tags' do
|
||||||
expect { subject.call(status, json, json) }
|
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: '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').statuses_count }.by(1)
|
||||||
.and change { status.account.featured_tags.find_by(name: 'bar').last_status_at }.from(nil).to(be_present)
|
.and change { status.account.featured_tags.find_by(name: 'bar').last_status_at }.from(nil).to(be_present)
|
||||||
|
|||||||
Reference in New Issue
Block a user