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:
Sony Mathew 2020-07-20 12:47:02 +05:30 committed by GitHub
parent 96efc44b82
commit b803ae3300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 8 deletions

View file

@ -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,

View file

@ -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

View file

@ -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)

View file

@ -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