2022-11-28 22:23:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-29 08:15:52 +00:00
|
|
|
class UnreactService < BaseService
|
2022-11-28 22:23:13 +00:00
|
|
|
include Payloadable
|
|
|
|
|
2022-12-01 01:41:47 +00:00
|
|
|
def call(account, status, name)
|
|
|
|
reaction = StatusReaction.find_by(account: account, status: status, name: name)
|
2022-11-28 22:23:13 +00:00
|
|
|
return if reaction.nil?
|
|
|
|
|
|
|
|
reaction.destroy!
|
|
|
|
|
|
|
|
json = Oj.dump(serialize_payload(reaction, ActivityPub::UndoEmojiReactionSerializer))
|
|
|
|
if status.account.local?
|
|
|
|
ActivityPub::RawDistributionWorker.perform_async(json, status.account.id)
|
|
|
|
else
|
|
|
|
ActivityPub::DeliveryWorker.perform_async(json, reaction.account_id, status.account.inbox_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
reaction
|
|
|
|
end
|
|
|
|
end
|