From 0afa5c297f3a39ffae133f0d8edf526cf1969426 Mon Sep 17 00:00:00 2001 From: Sony Mathew Date: Mon, 30 Mar 2020 16:07:01 +0530 Subject: [PATCH] Bug: Fixed conversation reply mail issue when an attachment is sent (#655) * When an attachment was sent in the reply mailer it was breaking due to the truncating function applied on the last message content. Here the content was empty and so it broke. * Fixed this breakage * Also addressed the issue that if the attachment was there the content was coming empty. With these changes, made the content to have a link to the attachment. --- app/mailers/conversation_reply_mailer.rb | 5 +++-- .../conversation_reply_mailer/reply_with_summary.html.erb | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/mailers/conversation_reply_mailer.rb b/app/mailers/conversation_reply_mailer.rb index 9fe65d231..ce8a91670 100644 --- a/app/mailers/conversation_reply_mailer.rb +++ b/app/mailers/conversation_reply_mailer.rb @@ -20,7 +20,8 @@ class ConversationReplyMailer < ApplicationMailer private - def mail_subject(last_message, trim_length = 30) - "[##{@conversation.display_id}] #{last_message.content.truncate(trim_length)}" + def mail_subject(last_message, trim_length = 50) + subject_line = last_message&.content&.truncate(trim_length) || 'New messages on this conversation' + "[##{@conversation.display_id}] #{subject_line}" end end diff --git a/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb b/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb index ecc93eeba..51e486380 100644 --- a/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb +++ b/app/views/mailers/conversation_reply_mailer/reply_with_summary.html.erb @@ -8,7 +8,13 @@ <%= message.incoming? ? 'You' : message.user.name %> - : <%= message.content %> + : + <% if message.attachment %> + attachment [click here to view] + <% else %> + <%= message.content %> + <% end %> + <% end %>