diff --git a/app/builders/messages/message_builder.rb b/app/builders/messages/message_builder.rb index b6ae5409d..a30394edc 100644 --- a/app/builders/messages/message_builder.rb +++ b/app/builders/messages/message_builder.rb @@ -16,6 +16,7 @@ class Messages::MessageBuilder def perform @message = @conversation.messages.build(message_params) process_attachments + process_emails @message.save! @message end @@ -34,6 +35,16 @@ class Messages::MessageBuilder end end + def process_emails + return unless @conversation.inbox&.inbox_type == 'Email' + + cc_emails = @params[:cc_emails].split(',') if @params[:cc_emails] + bcc_emails = @params[:bcc_emails].split(',') if @params[:bcc_emails] + + @message.content_attributes[:cc_emails] = cc_emails + @message.content_attributes[:bcc_emails] = bcc_emails + end + def message_type if @conversation.inbox.channel_type != 'Channel::Api' && @message_type == 'incoming' raise StandardError, 'Incoming messages are only allowed in Api inboxes' diff --git a/app/javascript/dashboard/api/inbox/message.js b/app/javascript/dashboard/api/inbox/message.js index 98c250e60..39bb5eb04 100644 --- a/app/javascript/dashboard/api/inbox/message.js +++ b/app/javascript/dashboard/api/inbox/message.js @@ -8,6 +8,8 @@ export const buildCreatePayload = ({ contentAttributes, echoId, file, + ccEmails, + bccEmails, }) => { let payload; if (file) { @@ -18,12 +20,16 @@ export const buildCreatePayload = ({ } payload.append('private', isPrivate); payload.append('echo_id', echoId); + payload.append('cc_emails', ccEmails); + payload.append('bcc_emails', bccEmails); } else { payload = { content: message, private: isPrivate, echo_id: echoId, content_attributes: contentAttributes, + cc_emails: ccEmails, + bcc_emails: bccEmails, }; } return payload; @@ -41,6 +47,8 @@ class MessageApi extends ApiClient { contentAttributes, echo_id: echoId, file, + ccEmails, + bccEmails, }) { return axios({ method: 'post', @@ -51,6 +59,8 @@ class MessageApi extends ApiClient { contentAttributes, echoId, file, + ccEmails, + bccEmails, }), }); } diff --git a/app/javascript/dashboard/components/widgets/conversation/Message.vue b/app/javascript/dashboard/components/widgets/conversation/Message.vue index e5de1b040..b3674681a 100644 --- a/app/javascript/dashboard/components/widgets/conversation/Message.vue +++ b/app/javascript/dashboard/components/widgets/conversation/Message.vue @@ -3,8 +3,9 @@