diff --git a/app/lib/activitypub/activity/emoji_react.rb b/app/lib/activitypub/activity/emoji_react.rb index c9d88bc51c..ad9f9abbaa 100644 --- a/app/lib/activitypub/activity/emoji_react.rb +++ b/app/lib/activitypub/activity/emoji_react.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ActivityPub::Activity::EmojiReact < ActivityPub::Activity + CUSTOM_EMOJI_REGEX = /^:[^:]+:$/ + def perform original_status = status_from_uri(object_uri) name = @json['content'] @@ -8,7 +10,7 @@ class ActivityPub::Activity::EmojiReact < ActivityPub::Activity !original_status.account.local? || delete_arrived_first?(@json['id']) - if /^:.*:$/.match?(name) + if CUSTOM_EMOJI_REGEX.match?(name) name.delete! ':' custom_emoji = process_emoji_tags(name, @json['tag']) diff --git a/app/lib/activitypub/activity/like.rb b/app/lib/activitypub/activity/like.rb index 0063820825..8856f7be4c 100644 --- a/app/lib/activitypub/activity/like.rb +++ b/app/lib/activitypub/activity/like.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ActivityPub::Activity::Like < ActivityPub::Activity + CUSTOM_EMOJI_REGEX = /^:[^:]+:$/ + def perform original_status = status_from_uri(object_uri) return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id']) @@ -23,7 +25,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity name = @json['content'] || @json['_misskey_reaction'] return false if name.nil? - if /^:.*:$/.match?(name) + if CUSTOM_EMOJI_REGEX.match?(name) name.delete! ':' custom_emoji = process_emoji_tags(name, @json['tag']) diff --git a/app/lib/activitypub/activity/undo.rb b/app/lib/activitypub/activity/undo.rb index 5f9f1bbecb..0c7714d6ed 100644 --- a/app/lib/activitypub/activity/undo.rb +++ b/app/lib/activitypub/activity/undo.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ActivityPub::Activity::Undo < ActivityPub::Activity + CUSTOM_EMOJI_REGEX = /^:[^:]+:$/ + def perform case @object['type'] when 'Announce' @@ -125,7 +127,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity return if status.nil? || !status.account.local? - if /^:.*:$/.match?(name) + if CUSTOM_EMOJI_REGEX.match?(name) name.delete! ':' custom_emoji = process_emoji_tags(name, @object['tag'])