mirror of
https://github.com/mastodon/mastodon.git
synced 2024-10-20 16:46:08 +00:00
74ead7d106
* Change featured tag updates to add/remove activity * Fix to check for the existence of feature tag * Rename service and worker * Merge AddHashtagSerializer with AddSerializer * Undo removal of sidekiq_options
22 lines
598 B
Ruby
22 lines
598 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CreateFeaturedTagService < BaseService
|
|
include Payloadable
|
|
|
|
def call(account, name)
|
|
@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)
|
|
end
|
|
|
|
private
|
|
|
|
def build_json(featured_tag)
|
|
Oj.dump(serialize_payload(featured_tag, ActivityPub::AddSerializer, signer: @account))
|
|
end
|
|
end
|