2022-11-02 09:41:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-02 10:53:36 -04:00
|
|
|
class DirectMessageSerializer < ApplicationSerializer
|
2022-11-02 09:41:30 -04:00
|
|
|
has_many :users, serializer: UserWithCustomFieldsAndStatusSerializer, embed: :objects
|
|
|
|
|
|
|
|
def users
|
|
|
|
users = object.direct_message_users.map(&:user).map { |u| u || DeletedChatUser.new }
|
|
|
|
|
|
|
|
return users - [scope.user] if users.count > 1
|
|
|
|
users
|
|
|
|
end
|
|
|
|
end
|