fedibird-fe/app/services/pin_service.rb
2022-05-11 00:48:03 +09:00

26 lines
603 B
Ruby

# frozen_string_literal: true
class PinService < BaseService
def call(account, status)
@account = account
@status = status
return unless @account == @status.account
StatusPin.create!(account: @account, status: @status)
distribute_add_activity! if @account.local?
end
private
def distribute_add_activity!
json = ActiveModelSerializers::SerializableResource.new(
@status,
serializer: ActivityPub::AddSerializer,
adapter: ActivityPub::Adapter
).as_json
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), @account.id)
end
end