Hotfix: Fix for private note in conversation email notifications - Merge branch 'hotfix/1.4.1' into develop
This commit is contained in:
commit
a5cc3bae6c
3 changed files with 20 additions and 4 deletions
|
@ -9,8 +9,8 @@ class ConversationReplyMailer < ApplicationMailer
|
|||
@contact = @conversation.contact
|
||||
@agent = @conversation.assignee
|
||||
|
||||
recap_messages = @conversation.messages.where('created_at < ?', message_queued_time).order(created_at: :asc).last(10)
|
||||
new_messages = @conversation.messages.where('created_at >= ?', message_queued_time)
|
||||
recap_messages = @conversation.messages.chat.where('created_at < ?', message_queued_time).last(10)
|
||||
new_messages = @conversation.messages.chat.where('created_at >= ?', message_queued_time)
|
||||
|
||||
@messages = recap_messages + new_messages
|
||||
@messages = @messages.select(&:reportable?)
|
||||
|
|
|
@ -59,7 +59,7 @@ class Message < ApplicationRecord
|
|||
|
||||
# .succ is a hack to avoid https://makandracards.com/makandra/1057-why-two-ruby-time-objects-are-not-equal-although-they-appear-to-be
|
||||
scope :unread_since, ->(datetime) { where('EXTRACT(EPOCH FROM created_at) > (?)', datetime.to_i.succ) }
|
||||
scope :chat, -> { where.not(message_type: :activity).where.not(private: true) }
|
||||
scope :chat, -> { where.not(message_type: :activity).where(private: false) }
|
||||
default_scope { order(created_at: :asc) }
|
||||
|
||||
belongs_to :account
|
||||
|
|
|
@ -12,15 +12,31 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
|||
allow(class_instance).to receive(:smtp_config_set_or_development?).and_return(true)
|
||||
end
|
||||
|
||||
context 'when custom domain and email is not enabled' do
|
||||
context 'with all mails' do
|
||||
let(:conversation) { create(:conversation, assignee: agent) }
|
||||
let(:message) { create(:message, conversation: conversation) }
|
||||
let(:private_message) { create(:message, content: 'This is a private message', conversation: conversation) }
|
||||
let(:mail) { described_class.reply_with_summary(message.conversation, Time.zone.now).deliver_now }
|
||||
|
||||
it 'renders the subject' do
|
||||
expect(mail.subject).to eq("[##{message.conversation.display_id}] #{message.content.truncate(30)}")
|
||||
end
|
||||
|
||||
it 'not have private notes' do
|
||||
# make the message private
|
||||
private_message.private = true
|
||||
private_message.save
|
||||
|
||||
expect(mail.body.decoded).not_to include(private_message.content)
|
||||
expect(mail.body.decoded).to include(message.content)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when custom domain and email is not enabled' do
|
||||
let(:conversation) { create(:conversation, assignee: agent) }
|
||||
let(:message) { create(:message, conversation: conversation) }
|
||||
let(:mail) { described_class.reply_with_summary(message.conversation, Time.zone.now).deliver_now }
|
||||
|
||||
it 'renders the receiver email' do
|
||||
expect(mail.to).to eq([message&.conversation&.contact&.email])
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue