3a91f535fa
Instead of processing tag and then look for the custom emoji, let the processing return an emoji. Add `name` to `process_emoji_tags` to check if it matches the shortcode. Removed `process_single_emoji` and added its code to `process_emoji_tags` Removed arg from `maybe_process_misskey_reaction`. Ideally, `original_status` should be a global object, but I wanted to modify vanilla code as little as possible. Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>
26 lines
828 B
Ruby
26 lines
828 B
Ruby
# 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? ||
|
|
!original_status.account.local? ||
|
|
delete_arrived_first?(@json['id'])
|
|
|
|
if /^:.*:$/.match?(name)
|
|
name.delete! ':'
|
|
custom_emoji = process_emoji_tags(@json['tag'])
|
|
|
|
return if custom_emoji.nil?
|
|
end
|
|
|
|
return if @account.reacted?(original_status, name, custom_emoji)
|
|
|
|
reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji)
|
|
|
|
LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction')
|
|
rescue ActiveRecord::RecordInvalid
|
|
nil
|
|
end
|
|
end
|