2022-11-28 23:23:13 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
|
|
|
def perform
|
|
|
|
original_status = status_from_uri(object_uri)
|
|
|
|
name = @json['content']
|
2024-01-18 19:39:59 +01:00
|
|
|
return if original_status.nil? || delete_arrived_first?(@json['id'])
|
2022-12-02 18:02:06 +01:00
|
|
|
|
2023-05-08 19:37:56 +02:00
|
|
|
if /^:.*:$/.match?(name)
|
2022-12-02 18:02:06 +01:00
|
|
|
name.delete! ':'
|
2023-05-27 13:09:48 +02:00
|
|
|
custom_emoji = process_emoji_tags(name, @json['tag'])
|
2023-05-27 12:19:29 +02:00
|
|
|
|
2022-12-03 11:22:15 +01:00
|
|
|
return if custom_emoji.nil?
|
2022-12-02 18:02:06 +01:00
|
|
|
end
|
2022-11-28 23:23:13 +01:00
|
|
|
|
2023-05-27 12:19:29 +02:00
|
|
|
return if @account.reacted?(original_status, name, custom_emoji)
|
|
|
|
|
2022-12-03 11:22:15 +01:00
|
|
|
reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji)
|
2022-11-29 06:21:53 +01:00
|
|
|
|
|
|
|
LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction')
|
2023-05-27 12:19:29 +02:00
|
|
|
rescue ActiveRecord::RecordInvalid
|
|
|
|
nil
|
2022-11-28 23:23:13 +01:00
|
|
|
end
|
|
|
|
end
|