1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-16 23:59:11 +09:00
YuruToot/app/services/unreact_service.rb

22 lines
582 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-11-29 17:15:52 +09:00
class UnreactService < BaseService
include Payloadable
def call(account, status)
reaction = StatusReaction.find_by(account: account, status: status)
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