Add glitch-toc emoji_reaction support

This commit is contained in:
KMY 2023-05-15 08:09:22 +09:00
parent fec0f7e009
commit 5a638a9551
16 changed files with 50 additions and 9 deletions

View file

@ -84,6 +84,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
max_reactions: EmojiReaction::EMOJI_REACTION_LIMIT,
max_reactions_per_account: EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT,
},
reactions: {
max_reactions: EmojiReaction::EMOJI_REACTION_LIMIT,
},
}
end

View file

@ -13,7 +13,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
end
def status_type?
[:favourite, :emoji_reaction, :reblog, :status, :mention, :poll, :update].include?(object.type)
[:favourite, :emoji_reaction, :reaction, :reblog, :status, :mention, :poll, :update].include?(object.type)
end
def report_type?

View file

@ -6,13 +6,14 @@ class REST::StatusSerializer < ActiveModel::Serializer
attributes :id, :created_at, :in_reply_to_id, :in_reply_to_account_id,
:sensitive, :spoiler_text, :visibility, :visibility_ex, :language,
:uri, :url, :replies_count, :reblogs_count, :searchability, :markdown,
:favourites_count, :emoji_reactions, :emoji_reactions_count, :edited_at
:favourites_count, :emoji_reactions, :emoji_reactions_count, :reactions, :edited_at
attribute :favourited, if: :current_user?
attribute :reblogged, if: :current_user?
attribute :muted, if: :current_user?
attribute :bookmarked, if: :current_user?
attribute :pinned, if: :pinnable?
attribute :reactions, if: :reactions?
has_many :filtered, serializer: REST::FilterResultSerializer, if: :current_user?
attribute :content, unless: :source_requested?
@ -103,6 +104,17 @@ class REST::StatusSerializer < ActiveModel::Serializer
object.emoji_reactions_grouped_by_name(current_user&.account)
end
def reactions
emoji_reactions.tap do |rs|
rs.each do |emoji_reaction|
emoji_reaction['name'] = emoji_reaction['domain'].present? ? "#{emoji_reaction['name']}@#{emoji_reaction['domain']}" : emoji_reaction['name']
emoji_reaction.delete('account_ids')
emoji_reaction.delete('me')
emoji_reaction.delete('domain')
end
end
end
def reblogged
if instance_options && instance_options[:relationships]
instance_options[:relationships].reblogs_map[object.id] || false
@ -150,6 +162,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
%w(public unlisted public_unlisted private).include?(object.visibility)
end
def reactions?
current_user? && current_user.setting_emoji_reaction_streaming_notify_impl2
end
def source_requested?
instance_options[:source_requested]
end

View file

@ -90,6 +90,10 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
max_reactions: EmojiReaction::EMOJI_REACTION_LIMIT,
max_reactions_per_account: EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT,
},
reactions: {
max_reactions: EmojiReaction::EMOJI_REACTION_LIMIT,
},
}
end