mirror of
https://github.com/funamitech/mastodon
synced 2024-12-16 07:38:27 +09:00
f4f1cc9eab
Handling remote reactions with foreign emojis would require an extensive rewrite of vanilla code, so instead prevent reactions with remote emojis when the status is not local. Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>
32 lines
1.0 KiB
Ruby
32 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class ReactService < BaseService
|
|
include Authorization
|
|
include Payloadable
|
|
|
|
def call(account, status, emoji)
|
|
authorize_with account, status, :react?
|
|
|
|
name, domain = emoji.split('@')
|
|
return unless domain.nil? || status.local?
|
|
|
|
custom_emoji = CustomEmoji.find_by(shortcode: name, domain: domain)
|
|
reaction = StatusReaction.find_by(account: account, status: status, name: name, custom_emoji: custom_emoji)
|
|
return reaction unless reaction.nil?
|
|
|
|
reaction = StatusReaction.create!(account: account, status: status, name: name, custom_emoji: custom_emoji)
|
|
|
|
json = Oj.dump(serialize_payload(reaction, ActivityPub::EmojiReactionSerializer))
|
|
if status.account.local?
|
|
NotifyService.new.call(status.account, :reaction, reaction)
|
|
ActivityPub::RawDistributionWorker.perform_async(json, status.account.id)
|
|
else
|
|
ActivityPub::DeliveryWorker.perform_async(json, reaction.account_id, status.account.inbox_url)
|
|
end
|
|
|
|
ActivityTracker.increment('activity:interactions')
|
|
|
|
reaction
|
|
end
|
|
end
|