fix: Update auto reply and hide reply time for email inbox (#3985)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Aswin Dev P.S 2022-02-15 03:41:28 -08:00 committed by GitHub
parent e6f8895c1b
commit 464e12ceb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 10 deletions

View file

@ -149,7 +149,7 @@
:richtext="!textAreaChannels" :richtext="!textAreaChannels"
/> />
</div> </div>
<label class="medium-9 columns settings-item"> <label v-if="isAWebWidgetInbox" class="medium-9 columns settings-item">
{{ $t('INBOX_MGMT.ADD.WEBSITE_CHANNEL.REPLY_TIME.TITLE') }} {{ $t('INBOX_MGMT.ADD.WEBSITE_CHANNEL.REPLY_TIME.TITLE') }}
<select v-model="replyTime"> <select v-model="replyTime">
<option key="in_a_few_minutes" value="in_a_few_minutes"> <option key="in_a_few_minutes" value="in_a_few_minutes">

View file

@ -136,6 +136,13 @@ class Message < ApplicationRecord
I18n.t('conversations.survey.response', link: "#{ENV['FRONTEND_URL']}/survey/responses/#{conversation.uuid}") I18n.t('conversations.survey.response', link: "#{ENV['FRONTEND_URL']}/survey/responses/#{conversation.uuid}")
end end
def email_notifiable_message?
return false if private? || incoming?
return false if template? && %w[input_csat text].exclude?(content_type)
true
end
private private
def ensure_content_type def ensure_content_type
@ -194,13 +201,6 @@ class Message < ApplicationRecord
email_notifiable_webwidget? || %w[Email].include?(inbox.inbox_type) email_notifiable_webwidget? || %w[Email].include?(inbox.inbox_type)
end end
def email_notifiable_message?
return false unless outgoing? || input_csat?
return false if private?
true
end
def can_notify_via_mail? def can_notify_via_mail?
return unless email_notifiable_message? return unless email_notifiable_message?
return unless email_notifiable_channel? return unless email_notifiable_channel?

View file

@ -5,8 +5,7 @@ class EmailReplyWorker
def perform(message_id) def perform(message_id)
message = Message.find(message_id) message = Message.find(message_id)
return unless message.outgoing? || message.input_csat? return unless message.email_notifiable_message?
return if message.private?
# send the email # send the email
ConversationReplyMailer.with(account: message.account).email_reply(message).deliver_later ConversationReplyMailer.with(account: message.account).email_reply(message).deliver_later

View file

@ -105,4 +105,33 @@ RSpec.describe Message, type: :model do
expect(message.content_type).to eq 'text' expect(message.content_type).to eq 'text'
end end
end end
context 'when email notifiable message' do
let(:message) { build(:message, content_type: nil, account: create(:account)) }
it 'return false if private message' do
message.private = true
expect(message.email_notifiable_message?).to be false
end
it 'return false if incoming message' do
message.private = false
message.message_type = 'incoming'
expect(message.email_notifiable_message?).to be false
end
it 'return false if message type is template and content type is not input_csat or text' do
message.private = false
message.message_type = 'template'
message.content_type = 'incoming_email'
expect(message.email_notifiable_message?).to be false
end
it 'return true if not private and not incoming and message content type is input_csat or text' do
message.private = false
message.message_type = 'template'
message.content_type = 'text'
expect(message.email_notifiable_message?).to be true
end
end
end end