diff --git a/app/finders/message_finder.rb b/app/finders/message_finder.rb index 8854e239a..bf82d61d5 100644 --- a/app/finders/message_finder.rb +++ b/app/finders/message_finder.rb @@ -48,3 +48,5 @@ class MessageFinder messages.reorder('created_at desc').limit(20).reverse end end + +MessageFinder.prepend_mod_with('MessageFinder') diff --git a/app/javascript/dashboard/api/channel/voice/twilioVoiceClient.js b/app/javascript/dashboard/api/channel/voice/twilioVoiceClient.js index 67f74a171..13f61a16c 100644 --- a/app/javascript/dashboard/api/channel/voice/twilioVoiceClient.js +++ b/app/javascript/dashboard/api/channel/voice/twilioVoiceClient.js @@ -68,7 +68,7 @@ class TwilioVoiceClient extends EventTarget { this.inboxId = null; } - async joinClientCall({ to, conversationId }) { + async joinClientCall({ to, conversationId, callSid }) { if (!this.device || !this.initialized || !to) return null; if (this.activeConnection) return this.activeConnection; @@ -76,6 +76,7 @@ class TwilioVoiceClient extends EventTarget { To: to, is_agent: 'true', conversation_id: conversationId, + call_sid: callSid, }; const connection = await this.device.connect({ params }); diff --git a/app/javascript/dashboard/api/channel/voice/voiceAPIClient.js b/app/javascript/dashboard/api/channel/voice/voiceAPIClient.js index 6e1e548c8..41ff7007c 100644 --- a/app/javascript/dashboard/api/channel/voice/voiceAPIClient.js +++ b/app/javascript/dashboard/api/channel/voice/voiceAPIClient.js @@ -12,10 +12,10 @@ class VoiceAPI extends ApiClient { return ContactsAPI.initiateCall(contactId, inboxId).then(r => r.data); } - leaveConference(inboxId, conversationId) { + leaveConference({ inboxId, conversationId, callSid }) { return axios .delete(`${this.baseUrl()}/inboxes/${inboxId}/conference`, { - params: { conversation_id: conversationId }, + params: { conversation_id: conversationId, call_sid: callSid }, }) .then(r => r.data); } diff --git a/app/javascript/dashboard/components-next/Conversation/ConversationCard/ConversationCardExpanded.vue b/app/javascript/dashboard/components-next/Conversation/ConversationCard/ConversationCardExpanded.vue index 5a6324902..d0f8f0211 100644 --- a/app/javascript/dashboard/components-next/Conversation/ConversationCard/ConversationCardExpanded.vue +++ b/app/javascript/dashboard/components-next/Conversation/ConversationCard/ConversationCardExpanded.vue @@ -35,10 +35,16 @@ const emit = defineEmits([ const lastMessageInChat = computed(() => getLastMessage(props.chat)); const showLabelsSection = computed(() => props.chat.labels?.length > 0); -const voiceCallData = computed(() => ({ - status: props.chat.additional_attributes?.call_status, - direction: props.chat.additional_attributes?.call_direction, -})); +const voiceCallData = computed(() => { + const last = lastMessageInChat.value; + if (last?.content_type !== 'voice_call' || !last.call) { + return { status: null, direction: null }; + } + return { + status: last.call.status, + direction: last.call.direction === 'outgoing' ? 'outbound' : 'inbound', + }; +}); const unreadCount = computed(() => props.chat.unread_count); diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index 3de9d2d04..d738bfcc6 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -113,6 +113,7 @@ const props = defineProps({ validator: value => Object.values(MESSAGE_STATUS).includes(value), }, attachments: { type: Array, default: () => [] }, + call: { type: Object, default: null }, // eslint-disable-line vue/no-unused-properties content: { type: String, default: null }, contentAttributes: { type: Object, default: () => ({}) }, contentType: { diff --git a/app/javascript/dashboard/components-next/message/bubbles/VoiceCall.vue b/app/javascript/dashboard/components-next/message/bubbles/VoiceCall.vue index 5a7d39a4e..a270882ac 100644 --- a/app/javascript/dashboard/components-next/message/bubbles/VoiceCall.vue +++ b/app/javascript/dashboard/components-next/message/bubbles/VoiceCall.vue @@ -1,7 +1,7 @@