Bugfix: Private notes in emails & broken Signup (#1068)
* Bugfix: Private notes in emails Private notes were sent in the emails as part of conversation continuity. Fixed this issue. Also made the changes to not even queue the mails if message is a private note. * Bugfix: Change issue with featurable in signup - passing array * Bugfix: Added specs for checking private notes being sent in email
This commit is contained in:
parent
96efc44b82
commit
b803ae3300
4 changed files with 14 additions and 8 deletions
|
@ -34,7 +34,8 @@ class ConversationReplyMailer < ApplicationMailer
|
|||
@contact = @conversation.contact
|
||||
@agent = @conversation.assignee
|
||||
|
||||
@messages = @conversation.messages.outgoing.where('created_at >= ?', message_queued_time)
|
||||
@messages = @conversation.messages.chat.outgoing.where('created_at >= ?', message_queued_time)
|
||||
return false if @messages.count.zero?
|
||||
|
||||
mail({
|
||||
to: @contact&.email,
|
||||
|
|
|
@ -55,6 +55,6 @@ module Featurable
|
|||
return true if config.blank?
|
||||
|
||||
features_to_enabled = config.value.select { |f| f[:enabled] }.map { |f| f[:name] }
|
||||
enable_features(features_to_enabled)
|
||||
enable_features(*features_to_enabled)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -146,7 +146,7 @@ class Message < ApplicationRecord
|
|||
end
|
||||
|
||||
def notify_via_mail
|
||||
if Redis::Alfred.get(conversation_mail_key).nil? && conversation.contact.email? && outgoing?
|
||||
if Redis::Alfred.get(conversation_mail_key).nil? && conversation.contact.email? && outgoing? && !private
|
||||
# set a redis key for the conversation so that we don't need to send email for every
|
||||
# new message that comes in and we dont enque the delayed sidekiq job for every message
|
||||
Redis::Alfred.setex(conversation_mail_key, Time.zone.now)
|
||||
|
|
|
@ -34,10 +34,16 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
|||
end
|
||||
|
||||
context 'without summary' do
|
||||
let(:conversation) { create(:conversation, assignee: agent) }
|
||||
let(:message_1) { create(:message, conversation: conversation) }
|
||||
let(:message_2) { build(:message, conversation: conversation, message_type: 'outgoing', content: 'Outgoing Message') }
|
||||
let(:private_message) { create(:message, content: 'This is a private message', conversation: conversation) }
|
||||
let(:conversation) { create(:conversation, assignee: agent, account: account).reload }
|
||||
let(:message_1) { create(:message, conversation: conversation, account: account, content: 'Outgoing Message 1').reload }
|
||||
let(:message_2) { build(:message, conversation: conversation, account: account, message_type: 'outgoing', content: 'Outgoing Message 2') }
|
||||
let(:private_message) do
|
||||
create(:message,
|
||||
content: 'This is a private message',
|
||||
conversation: conversation,
|
||||
account: account,
|
||||
message_type: 'outgoing').reload
|
||||
end
|
||||
let(:mail) { described_class.reply_without_summary(message_1.conversation, Time.zone.now - 1.minute).deliver_now }
|
||||
|
||||
before do
|
||||
|
@ -52,7 +58,6 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
|||
# make the message private
|
||||
private_message.private = true
|
||||
private_message.save
|
||||
|
||||
expect(mail.body.decoded).not_to include(private_message.content)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue