From a75f49ddcc57239ca0da88d97fe852ccf8a477dc Mon Sep 17 00:00:00 2001 From: sony-mathew Date: Sun, 10 May 2020 13:14:57 +0530 Subject: [PATCH] Bug: Fixed private note being sent to customer (#837) --- app/mailers/conversation_reply_mailer.rb | 4 ++-- app/models/message.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/mailers/conversation_reply_mailer.rb b/app/mailers/conversation_reply_mailer.rb index 4b41d81db..0b0b75669 100644 --- a/app/mailers/conversation_reply_mailer.rb +++ b/app/mailers/conversation_reply_mailer.rb @@ -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?) diff --git a/app/models/message.rb b/app/models/message.rb index 99572a751..47ea8c425 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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