mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 10:25:02 +08:00
abcaa1a961
This is a followup of the previous refactor where we created two new models to handle all the dedicated logic that was present in the `ChatChannel` model. For the sake of consistency, `DMChannel` has been renamed to `DirectMessageChannel` and the previous `DirectMessageChannel` model is now named `DirectMessage`. This should help reasoning about direct messages.
13 lines
347 B
Ruby
13 lines
347 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DirectMessageSerializer < ApplicationSerializer
|
|
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
|