2023-03-08 10:39:03 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-14 15:03:50 -04:00
|
|
|
class AiChatChannelSerializer < ApplicationSerializer
|
2023-06-16 13:37:16 -04:00
|
|
|
attributes :id, :chatable, :chatable_type, :chatable_url, :slug
|
|
|
|
|
2024-06-27 09:43:00 -04:00
|
|
|
def chatable
|
|
|
|
case object.chatable_type
|
|
|
|
when "Category"
|
|
|
|
BasicCategorySerializer.new(object.chatable, root: false).as_json
|
|
|
|
when "DirectMessage"
|
|
|
|
Chat::DirectMessageSerializer.new(object.chatable, scope: scope, root: false).as_json
|
|
|
|
when "Site"
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-06-16 13:37:16 -04:00
|
|
|
def title
|
|
|
|
# Display all participants for a DM.
|
|
|
|
# For category channels, the argument is ignored.
|
|
|
|
object.title(nil)
|
|
|
|
end
|
2023-03-08 10:39:03 -05:00
|
|
|
end
|