2022-11-28 14:23:13 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-29 00:15:52 -08:00
|
|
|
class UnreactService < BaseService
|
2022-11-28 14:23:13 -08:00
|
|
|
include Payloadable
|
|
|
|
|
2023-05-07 13:01:04 -07:00
|
|
|
def call(account, status, emoji)
|
2023-05-09 14:41:48 -07:00
|
|
|
name, domain = emoji.split('@')
|
|
|
|
custom_emoji = CustomEmoji.find_by(shortcode: name, domain: domain)
|
|
|
|
reaction = StatusReaction.find_by(account: account, status: status, name: name, custom_emoji: custom_emoji)
|
|
|
|
return if reaction.nil?
|
2022-11-28 14:23:13 -08:00
|
|
|
|
2023-05-09 14:41:48 -07:00
|
|
|
reaction.destroy!
|
2022-11-28 14:23:13 -08:00
|
|
|
|
2023-05-09 14:41:48 -07:00
|
|
|
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)
|
2023-05-07 13:01:04 -07:00
|
|
|
end
|
2023-05-09 14:41:48 -07:00
|
|
|
|
|
|
|
reaction
|
|
|
|
end
|
2022-11-28 14:23:13 -08:00
|
|
|
end
|