mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-28 01:21:36 +01:00
f4faa1b511
Turns out the strange error where it would delete the wrong reaction occurred because I forgot to pass the emoji name to the query, which resulted in the database deleting the first reaction it found. Also, this removes the unused set_reaction callback and includes the Authorization module for the status reactions controller.
21 lines
600 B
Ruby
21 lines
600 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UnreactService < BaseService
|
|
include Payloadable
|
|
|
|
def call(account, status, name)
|
|
reaction = StatusReaction.find_by(account: account, status: status, name: name)
|
|
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
|