2017-08-08 12:52:15 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::Activity::Like < ActivityPub::Activity
|
|
|
|
def perform
|
|
|
|
original_status = status_from_uri(object_uri)
|
2022-11-28 21:21:53 -08:00
|
|
|
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id'])
|
2017-08-08 12:52:15 -07:00
|
|
|
|
2022-11-28 21:21:53 -08:00
|
|
|
# misskey delivers reactions as likes and attaches the emoji in _misskey_reaction
|
|
|
|
mk_reaction = @json['_misskey_reaction']
|
|
|
|
unless mk_reaction.nil?
|
|
|
|
custom_emoji = CustomEmoji.find_by(shortcode: mk_reaction, domain: @account.domain)
|
|
|
|
return if @account.reacted?(original_status, mk_reaction, custom_emoji)
|
|
|
|
|
|
|
|
reaction = original_status.status_reactions.create!(account: @account, name: mk_reaction, custom_emoji: custom_emoji)
|
|
|
|
LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction')
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
return if @account.favourited?(original_status)
|
2017-08-08 12:52:15 -07:00
|
|
|
|
2017-08-20 07:53:47 -07:00
|
|
|
favourite = original_status.favourites.create!(account: @account)
|
2022-02-24 15:34:14 -08:00
|
|
|
|
2022-03-03 16:06:33 -08:00
|
|
|
LocalNotificationWorker.perform_async(original_status.account_id, favourite.id, 'Favourite', 'favourite')
|
2022-02-24 15:34:14 -08:00
|
|
|
Trends.statuses.register(original_status)
|
2017-08-08 12:52:15 -07:00
|
|
|
end
|
|
|
|
end
|