Fix Settings::FeaturedTagsController (#19418)

Regression from #19409
This commit is contained in:
Yamagishi Kazutoshi 2022-10-23 06:14:58 +09:00 committed by GitHub
parent 74ead7d106
commit 45d3b32488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View file

@ -3,14 +3,18 @@
class CreateFeaturedTagService < BaseService
include Payloadable
def call(account, name)
def call(account, name, force: true)
@account = account
FeaturedTag.create!(account: account, name: name).tap do |featured_tag|
ActivityPub::AccountRawDistributionWorker.perform_async(build_json(featured_tag), account.id) if @account.local?
end
rescue ActiveRecord::RecordNotUnique
FeaturedTag.by_name(name).find_by!(account: account)
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid => e
if force && e.is_a(ActiveRecord::RecordNotUnique)
FeaturedTag.by_name(name).find_by!(account: account)
else
account.featured_tags.new(name: name)
end
end
private