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.
This commit is contained in:
Sony Mathew 2020-03-30 16:07:01 +05:30 committed by GitHub
parent 6c4e1fdaac
commit 0afa5c297f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

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

View file

@ -8,7 +8,13 @@
<td>
<b><%= message.incoming? ? 'You' : message.user.name %></b>
</td>
<td>: <%= message.content %></td>
<td>:
<% if message.attachment %>
attachment [<a href="<%= message.attachment.file_url %>" _target="blank">click here to view</a>]
<% else %>
<%= message.content %>
<% end %>
</td>
</tr>
<% end %>
</table>