2022-11-29 07:23:13 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
|
|
|
def perform
|
|
|
|
original_status = status_from_uri(object_uri)
|
|
|
|
name = @json['content']
|
|
|
|
return if original_status.nil? ||
|
2022-12-03 02:02:06 +09:00
|
|
|
!original_status.account.local? ||
|
|
|
|
delete_arrived_first?(@json['id']) ||
|
|
|
|
@account.reacted?(original_status, name)
|
|
|
|
|
2022-12-03 19:22:15 +09:00
|
|
|
custom_emoji = nil
|
2023-05-10 06:41:48 +09:00
|
|
|
if /^:.*:$/.match?(name)
|
2022-12-03 19:22:15 +09:00
|
|
|
process_emoji_tags(@json['tag'])
|
2022-12-03 02:02:06 +09:00
|
|
|
|
|
|
|
name.delete! ':'
|
2022-12-03 19:22:15 +09:00
|
|
|
custom_emoji = CustomEmoji.find_by(shortcode: name, domain: @account.domain)
|
|
|
|
return if custom_emoji.nil?
|
2022-12-03 02:02:06 +09:00
|
|
|
end
|
2022-11-29 07:23:13 +09:00
|
|
|
|
2022-12-03 19:22:15 +09:00
|
|
|
reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji)
|
2022-11-29 14:21:53 +09:00
|
|
|
|
|
|
|
LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction')
|
2022-11-29 07:23:13 +09:00
|
|
|
end
|
|
|
|
end
|