notification_serializer.rb 445 B

12345678910111213141516
  1. # frozen_string_literal: true
  2. class REST::NotificationSerializer < ActiveModel::Serializer
  3. attributes :id, :type, :created_at
  4. belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
  5. belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
  6. def id
  7. object.id.to_s
  8. end
  9. def status_type?
  10. [:favourite, :reblog, :status, :mention, :poll].include?(object.type)
  11. end
  12. end