Add emoji icon support on notification (expects custom)
This commit is contained in:
parent
b242a89e63
commit
1df6e80ee0
5 changed files with 17 additions and 4 deletions
|
@ -1,15 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::EmojiReactionSerializer < ActiveModel::Serializer
|
||||
attributes :name, :count
|
||||
attributes :name
|
||||
|
||||
attribute :count, if: :count?
|
||||
attribute :url, if: :custom_emoji?
|
||||
attribute :static_url, if: :custom_emoji?
|
||||
attribute :domain, if: :custom_emoji?
|
||||
attribute :account_ids, if: :account_ids?
|
||||
|
||||
def count?
|
||||
object.respond_to?(:count)
|
||||
end
|
||||
|
||||
def custom_emoji?
|
||||
object.url.present?
|
||||
object.respond_to?(:url)
|
||||
end
|
||||
|
||||
def account_ids?
|
||||
|
|
|
@ -6,6 +6,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
|||
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
|
||||
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
|
||||
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
|
||||
belongs_to :emoji_reaction, if: :emoji_reaction_type?, serializer: REST::EmojiReactionSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
@ -18,4 +19,8 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
|||
def report_type?
|
||||
object.type == :'admin.report'
|
||||
end
|
||||
|
||||
def emoji_reaction_type?
|
||||
object.type == :emoji_reaction
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue