mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
Previously, chat interaction responses could include details that were not part of the public message representation. This change keeps the interaction response aligned with the rendered button data and adds regression coverage.
23 lines
553 B
Ruby
Vendored
23 lines
553 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Chat
|
|
class MessageInteractionSerializer < ::ApplicationSerializer
|
|
attributes :user, :channel, :message, :action
|
|
|
|
def user
|
|
{ id: object.user.id, username: object.user.username }
|
|
end
|
|
|
|
def channel
|
|
{ id: object.message.chat_channel.id, title: object.message.chat_channel.title(scope.user) }
|
|
end
|
|
|
|
def message
|
|
{ id: object.message.id, text: object.message.message, user_id: object.message.user.id }
|
|
end
|
|
|
|
def action
|
|
object.action.except("value")
|
|
end
|
|
end
|
|
end
|