feat(voice): embed Call in voice_call message payload
Adds a nested `call` object to the voice_call message JSON / push payload so the frontend can read call state directly from message.call instead of duplicating it in content_attributes.data. - Message gains has_one :call (inverse of existing Call#belongs_to :message) via enterprise module prepend. - Message serializer (_message.json.jbuilder) emits a call block for voice_call messages when the Call is linked. - Message#push_event_data mirrors the payload into socket broadcasts. - MessageFinder eager-loads the call (+ contact + inbox.channel) to avoid N+1 when listing conversation messages. - Call gains helper methods: display_status, from_number, to_number, recording_url, push_event_data. These centralize the direction- and status-aware derivations so jbuilder and push_event_data stay in sync. Frontend continues to read content_attributes.data — this commit only adds the new shape; a follow-up swaps readers to message.call.
This commit is contained in:
@@ -152,9 +152,14 @@ class Message < ApplicationRecord
|
||||
)
|
||||
data[:echo_id] = echo_id if echo_id.present?
|
||||
data[:attachments] = attachments.map(&:push_event_data) if attachments.present?
|
||||
data[:call] = call.push_event_data if voice_call? && respond_to?(:call) && call.present?
|
||||
merge_sender_attributes(data)
|
||||
end
|
||||
|
||||
def voice_call?
|
||||
content_type == 'voice_call'
|
||||
end
|
||||
|
||||
def conversation_push_event_data
|
||||
{
|
||||
assignee_id: conversation.assignee_id,
|
||||
|
||||
Reference in New Issue
Block a user