0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/plugins/chat/app/serializers/chat/message_interaction_serializer.rb
Arpit Jalan 76c4bea628
FIX: filter chat interaction action payloads (#39981)
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.
2026-05-13 22:48:21 +05:30

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