gab-social/app/serializers/rest/chat_conversation_account_serializer.rb
mgabdev 137a36b810 Progress with DMs
Progress with DMs
2020-12-03 17:13:11 -05:00

26 lines
638 B
Ruby

# frozen_string_literal: true
class REST::ChatConversationAccountSerializer < ActiveModel::Serializer
attributes :id, :is_hidden, :is_approved, :unread_count, :is_unread, :chat_conversation_id, :created_at
has_many :participant_accounts, key: :other_accounts, serializer: REST::AccountSerializer
has_one :last_chat_message, serializer: REST::ChatMessageSerializer, unless: :last_chat_message_id?
def id
object.id.to_s
end
def chat_conversation_id
object.chat_conversation_id.to_s
end
def last_chat_message_id?
object.last_chat_message_id.nil?
end
def is_unread
object.unread_count > 0
end
end