Change to interpret emoji reaction ⭐ as favorite
This commit is contained in:
parent
4803329dce
commit
933485dcec
3 changed files with 25 additions and 8 deletions
|
@ -52,7 +52,19 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
def shortcode
|
||||
return @shortcode if defined?(@shortcode)
|
||||
|
||||
@shortcode = @json['_misskey_reaction']&.delete(':')
|
||||
@shortcode = begin
|
||||
if @json['_misskey_reaction'] == '⭐'
|
||||
nil
|
||||
else
|
||||
@json['content']&.delete(':')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def misskey_favourite?
|
||||
misskey_shortcode = @json['_misskey_reaction']&.delete(':')
|
||||
|
||||
return misskey_shortcode == shortcode && misskey_shortcode == '⭐'
|
||||
end
|
||||
|
||||
def emoji_tag
|
||||
|
|
|
@ -112,8 +112,6 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
|||
|
||||
return if status.nil? || !status.account.local?
|
||||
|
||||
shortcode = @object['_misskey_reaction']&.delete(':')
|
||||
|
||||
if shortcode.present?
|
||||
emoji_tag = @object['tag'].is_a?(Array) ? @object['tag']&.first : @object['tag']
|
||||
|
||||
|
@ -135,6 +133,18 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
|||
end
|
||||
end
|
||||
|
||||
def shortcode
|
||||
return @shortcode if defined?(@shortcode)
|
||||
|
||||
@shortcode = begin
|
||||
if @object['_misskey_reaction'] == '⭐'
|
||||
nil
|
||||
else
|
||||
@object['content']&.delete(':')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def undo_react
|
||||
@account.emoji_reactions.find_by(uri: object_uri)&.destroy
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
||||
attributes :id, :type, :actor, :content
|
||||
attribute :virtual_object, key: :object
|
||||
attribute :misskey_reaction, key: :_misskey_reaction
|
||||
|
||||
has_one :custom_emoji ,key: :tag, serializer: ActivityPub::EmojiSerializer, unless: -> { object.custom_emoji.nil? }
|
||||
|
||||
|
@ -26,8 +25,4 @@ class ActivityPub::EmojiReactionSerializer < ActivityPub::Serializer
|
|||
def content
|
||||
object.custom_emoji.nil? ? object.name : ":#{object.name}:"
|
||||
end
|
||||
|
||||
def misskey_reaction
|
||||
object.custom_emoji.nil? ? object.name : ":#{object.name}:"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue