mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-29 05:11:37 +01:00
Turn custom emoji regexps into class level constants
This commit is contained in:
parent
0fb3dcf085
commit
75d16a4814
3 changed files with 9 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
||||||
|
CUSTOM_EMOJI_REGEX = /^:[^:]+:$/
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
original_status = status_from_uri(object_uri)
|
original_status = status_from_uri(object_uri)
|
||||||
name = @json['content']
|
name = @json['content']
|
||||||
|
@ -8,7 +10,7 @@ class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
||||||
!original_status.account.local? ||
|
!original_status.account.local? ||
|
||||||
delete_arrived_first?(@json['id'])
|
delete_arrived_first?(@json['id'])
|
||||||
|
|
||||||
if /^:.*:$/.match?(name)
|
if CUSTOM_EMOJI_REGEX.match?(name)
|
||||||
name.delete! ':'
|
name.delete! ':'
|
||||||
custom_emoji = process_emoji_tags(name, @json['tag'])
|
custom_emoji = process_emoji_tags(name, @json['tag'])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::Activity::Like < ActivityPub::Activity
|
class ActivityPub::Activity::Like < ActivityPub::Activity
|
||||||
|
CUSTOM_EMOJI_REGEX = /^:[^:]+:$/
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
original_status = status_from_uri(object_uri)
|
original_status = status_from_uri(object_uri)
|
||||||
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id'])
|
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']
|
name = @json['content'] || @json['_misskey_reaction']
|
||||||
return false if name.nil?
|
return false if name.nil?
|
||||||
|
|
||||||
if /^:.*:$/.match?(name)
|
if CUSTOM_EMOJI_REGEX.match?(name)
|
||||||
name.delete! ':'
|
name.delete! ':'
|
||||||
custom_emoji = process_emoji_tags(name, @json['tag'])
|
custom_emoji = process_emoji_tags(name, @json['tag'])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::Activity::Undo < ActivityPub::Activity
|
class ActivityPub::Activity::Undo < ActivityPub::Activity
|
||||||
|
CUSTOM_EMOJI_REGEX = /^:[^:]+:$/
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
case @object['type']
|
case @object['type']
|
||||||
when 'Announce'
|
when 'Announce'
|
||||||
|
@ -125,7 +127,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
||||||
|
|
||||||
return if status.nil? || !status.account.local?
|
return if status.nil? || !status.account.local?
|
||||||
|
|
||||||
if /^:.*:$/.match?(name)
|
if CUSTOM_EMOJI_REGEX.match?(name)
|
||||||
name.delete! ':'
|
name.delete! ':'
|
||||||
custom_emoji = process_emoji_tags(name, @object['tag'])
|
custom_emoji = process_emoji_tags(name, @object['tag'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue