From 6137a45214c39685b72a146b0989f8c82c12fbb9 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Wed, 10 May 2023 06:09:09 +0530 Subject: [PATCH 1/6] chore: Update link in the reply summary email (#7024) Co-authored-by: Pranav Raj S --- app/models/conversation.rb | 4 ++++ .../reply_with_summary.html.erb | 22 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/models/conversation.rb b/app/models/conversation.rb index fa59e8d24..e01fb3863 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -195,6 +195,10 @@ class Conversation < ApplicationRecord messages.chat.last(5) end + def csat_survey_link + "#{ENV.fetch('FRONTEND_URL', nil)}/survey/responses/#{uuid}" + end + private def execute_after_update_commit_callbacks diff --git a/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb b/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb index 34665b777..c6cb77ad2 100644 --- a/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb +++ b/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb @@ -5,18 +5,26 @@ <% @messages.each do |message| %> - <%= message.incoming? ? 'You' : message.sender&.available_name || message.sender&.name %> + <%= message.incoming? ? 'You' : message.sender&.available_name || message.sender&.name || 'Bot' %> - - <% if message.content %> + + <% if (message.content_type == 'input_csat' && message.message_type == 'template') %> +

Click here to rate the conversation.

+ <% elsif message.content.present? %> <%= CommonMarker.render_html(message.content).html_safe %> <% end %> - <% if message.attachments %> - <% message.attachments.each do |attachment| %> - Attachment [Click here to view] - <% end %> + <% if message.attachments.count.positive? %> +

+ <% if message.content.present? %> +


+ <% end %> + This message contains <%= message.attachments.count > 1 ? 'attachments' : 'an attachment' %>. + <% message.attachments.each do |attachment| %> +
- View the attachment here. + <% end %> +

<% end %> From 662967b5d384bda8359e9d00c5570015ce847ffd Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 10 May 2023 11:34:49 +0530 Subject: [PATCH 2/6] feat(perf): add index to messages created at (#7044) * feat: add index to messages created at * feat: run migration --- app/models/message.rb | 1 + .../20230509101256_add_index_to_messages_created_at.rb | 6 ++++++ db/schema.rb | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230509101256_add_index_to_messages_created_at.rb diff --git a/app/models/message.rb b/app/models/message.rb index 3b1ddda11..a73cbfd66 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -27,6 +27,7 @@ # index_messages_on_additional_attributes_campaign_id (((additional_attributes -> 'campaign_id'::text))) USING gin # index_messages_on_content (content) USING gin # index_messages_on_conversation_id (conversation_id) +# index_messages_on_created_at (created_at) # index_messages_on_inbox_id (inbox_id) # index_messages_on_sender_type_and_sender_id (sender_type,sender_id) # index_messages_on_source_id (source_id) diff --git a/db/migrate/20230509101256_add_index_to_messages_created_at.rb b/db/migrate/20230509101256_add_index_to_messages_created_at.rb new file mode 100644 index 000000000..0bee32749 --- /dev/null +++ b/db/migrate/20230509101256_add_index_to_messages_created_at.rb @@ -0,0 +1,6 @@ +class AddIndexToMessagesCreatedAt < ActiveRecord::Migration[7.0] + disable_ddl_transaction! + def change + add_index :messages, [:created_at], name: 'index_messages_on_created_at', algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index d3753968a..84f3af8fc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_04_26_130150) do +ActiveRecord::Schema[7.0].define(version: 2023_05_09_101256) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm" @@ -667,6 +667,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_26_130150) do t.index ["account_id"], name: "index_messages_on_account_id" t.index ["content"], name: "index_messages_on_content", opclass: :gin_trgm_ops, using: :gin t.index ["conversation_id"], name: "index_messages_on_conversation_id" + t.index ["created_at"], name: "index_messages_on_created_at" t.index ["inbox_id"], name: "index_messages_on_inbox_id" t.index ["sender_type", "sender_id"], name: "index_messages_on_sender_type_and_sender_id" t.index ["source_id"], name: "index_messages_on_source_id" From 520bdabefe8867d1bae2a8e5be9b0040ffcd97e8 Mon Sep 17 00:00:00 2001 From: giquieu Date: Wed, 10 May 2023 03:59:56 -0300 Subject: [PATCH 3/6] fix: Record audio in wav format for web/facebook (#7046) --- .../widgets/WootWriter/AudioRecorder.vue | 39 ++++++++++--------- .../widgets/conversation/ReplyBox.vue | 6 +-- app/javascript/shared/constants/messages.js | 1 + 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/WootWriter/AudioRecorder.vue b/app/javascript/dashboard/components/widgets/WootWriter/AudioRecorder.vue index 68072c846..55db1aad8 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/AudioRecorder.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/AudioRecorder.vue @@ -13,15 +13,19 @@ import videojs from 'video.js'; import alertMixin from '../../../../shared/mixins/alertMixin'; import Recorder from 'opus-recorder'; + +// Workers to record Audio .ogg and .wav import encoderWorker from 'opus-recorder/dist/encoderWorker.min'; import waveWorker from 'opus-recorder/dist/waveWorker.min'; import WaveSurfer from 'wavesurfer.js'; import MicrophonePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.microphone.js'; -import 'videojs-wavesurfer/dist/videojs.wavesurfer.js'; +import 'videojs-wavesurfer/dist/videojs.wavesurfer.js'; import 'videojs-record/dist/videojs.record.js'; -import 'videojs-record/dist/plugins/videojs.record.opus-recorder.js'; + +import OpusRecorderEngine from 'videojs-record/dist/plugins/videojs.record.opus-recorder.js'; + import { format, addSeconds } from 'date-fns'; import { AUDIO_FORMATS } from 'shared/constants/messages'; @@ -33,7 +37,7 @@ export default { props: { audioRecordFormat: { type: String, - default: AUDIO_FORMATS.WEBM, + default: AUDIO_FORMATS.WAV, }, }, data() { @@ -79,24 +83,18 @@ export default { maxLength: 900, timeSlice: 1000, maxFileSize: 15 * 1024 * 1024, - ...(this.audioRecordFormat === AUDIO_FORMATS.WEBM && { - monitorGain: 0, - recordingGain: 1, - numberOfChannels: 1, - encoderSampleRate: 16000, - originalSampleRateOverride: 16000, - streamPages: true, - maxFramesPerPage: 1, - encoderFrameSize: 1, - encoderPath: waveWorker, + displayMilliseconds: false, + audioChannels: 1, + audioSampleRate: 48000, + audioBitRate: 128, + audioEngine: 'opus-recorder', + ...(this.audioRecordFormat === AUDIO_FORMATS.WAV && { + audioMimeType: 'audio/wav', + audioWorkerURL: waveWorker, }), ...(this.audioRecordFormat === AUDIO_FORMATS.OGG && { - displayMilliseconds: false, - audioEngine: 'opus-recorder', + audioMimeType: 'audio/ogg', audioWorkerURL: encoderWorker, - audioChannels: 1, - audioSampleRate: 48000, - audioBitRate: 128, }), }, }, @@ -134,6 +132,11 @@ export default { }, methods: { deviceReady() { + if (this.player.record().engine instanceof OpusRecorderEngine) { + if (this.audioRecordFormat === AUDIO_FORMATS.WAV) { + this.player.record().engine.audioType = 'audio/wav'; + } + } this.player.record().start(); }, startRecord() { diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index bae30d407..1c6f4f796 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -501,10 +501,10 @@ export default { return `draft-${this.conversationIdByRoute}-${this.replyType}`; }, audioRecordFormat() { - if (this.isAWebWidgetInbox) { - return AUDIO_FORMATS.WEBM; + if (this.isAWhatsAppChannel) { + return AUDIO_FORMATS.OGG; } - return AUDIO_FORMATS.OGG; + return AUDIO_FORMATS.WAV; }, messageVariables() { const variables = getMessageVariables({ diff --git a/app/javascript/shared/constants/messages.js b/app/javascript/shared/constants/messages.js index 63ca99afc..77501cb76 100644 --- a/app/javascript/shared/constants/messages.js +++ b/app/javascript/shared/constants/messages.js @@ -84,6 +84,7 @@ export const CSAT_RATINGS = [ export const AUDIO_FORMATS = { WEBM: 'audio/webm', OGG: 'audio/ogg', + WAV: 'audio/wav', }; export const MESSAGE_VARIABLES = [ From 07aaa046c17d50617ea95ad85a867941aa40183f Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Wed, 10 May 2023 15:55:48 +0530 Subject: [PATCH 4/6] fix: Welcome email copy changes and canned response API error handling [cw-1290] (#6905) * fix: Welcome email copy changes and canned response API error handling * Review fixes * Uses mixin for alerts in canned page * Typo fixes * Copy changes * Fixes broken tests * Fixes review comments * Fixes typo errors with mail template * Removes unwanted case * Fixes repetitive texts --------- Co-authored-by: Muhsin Keloth --- .../dashboard/i18n/locale/en/cannedMgmt.json | 6 +++--- .../dashboard/settings/canned/AddCanned.vue | 10 +++++---- .../dashboard/settings/canned/EditCanned.vue | 20 +++++++----------- .../dashboard/settings/canned/Index.vue | 6 ++++-- .../dashboard/store/modules/cannedResponse.js | 7 +++++++ .../mailer/confirmation_instructions.html.erb | 21 ++++++++++++------- .../mailers/confirmation_instructions_spec.rb | 4 ++-- 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json b/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json index 9c14f5a52..e3391967d 100644 --- a/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json @@ -34,7 +34,7 @@ }, "API": { "SUCCESS_MESSAGE": "Canned Response added successfully", - "ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later" + "ERROR_MESSAGE": "Could not create canned response, Please try again later" } }, "EDIT": { @@ -56,14 +56,14 @@ "BUTTON_TEXT": "Edit", "API": { "SUCCESS_MESSAGE": "Canned Response updated successfully", - "ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later" + "ERROR_MESSAGE": "Could not update canned response, Please try again later" } }, "DELETE": { "BUTTON_TEXT": "Delete", "API": { "SUCCESS_MESSAGE": "Canned response deleted successfully", - "ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later" + "ERROR_MESSAGE": "Could not delete canned response, Please try again later" }, "CONFIRM": { "TITLE": "Confirm Deletion", diff --git a/app/javascript/dashboard/routes/dashboard/settings/canned/AddCanned.vue b/app/javascript/dashboard/routes/dashboard/settings/canned/AddCanned.vue index 1f117eb81..10c17a003 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/canned/AddCanned.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/canned/AddCanned.vue @@ -5,7 +5,7 @@ :header-title="$t('CANNED_MGMT.ADD.TITLE')" :header-content="$t('CANNED_MGMT.ADD.DESC')" /> -
+