Change featured tag updates to add/remove activity (#19409)
* 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
This commit is contained in:
parent
73a48318a1
commit
74ead7d106
10 changed files with 117 additions and 15 deletions
21
app/services/create_featured_tag_service.rb
Normal file
21
app/services/create_featured_tag_service.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# 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
|
18
app/services/remove_featured_tag_service.rb
Normal file
18
app/services/remove_featured_tag_service.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveFeaturedTagService < BaseService
|
||||
include Payloadable
|
||||
|
||||
def call(account, featured_tag)
|
||||
@account = account
|
||||
|
||||
featured_tag.destroy!
|
||||
ActivityPub::AccountRawDistributionWorker.perform_async(build_json(featured_tag), account.id) if @account.local?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_json(featured_tag)
|
||||
Oj.dump(serialize_payload(featured_tag, ActivityPub::RemoveSerializer, signer: @account))
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue