fedibird-fe/app/lib/activitypub/activity/emoji_react.rb

15 lines
756 B
Ruby

# frozen_string_literal: true
class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
def perform
original_status = status_from_uri(object_uri)
shortcode = @json['content']
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id']) || @account.reacted?(original_status, shortcode)
return if original_status.account.blocking?(@account) || @account.blocking?(original_status.account) || original_status.account.domain_blocking?(@account.domain)
reaction = original_status.emoji_reactions.create!(account: @account, name: shortcode, uri: @json['id'])
NotifyService.new.call(original_status.account, :emoji_reaction, reaction) if original_status.account.local?
end
end