Skip to content

Commit

Permalink
Fix DABBLE-ME-6F
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Aug 31, 2024
1 parent 9e7c2b5 commit e51095e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def process
end
else
begin
entry = @user.entries.create!(date: date, inspiration_id: inspiration_id, body: @body, original_email_body: @raw_body)
params = { date: date, inspiration_id: inspiration_id, body: @body, original_email_body: @raw_body }
entry = @user.entries.create!(params)
if best_attachment.present?
entry.image = best_attachment
elsif best_attachment_url.present? && best_attachment_url.starts_with?("mailgun_collage:")
Expand Down Expand Up @@ -314,6 +315,7 @@ def clean_message(body)
body&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break
body&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break
body&.gsub!("p.MsoNormal,p.MsoNoSpacing{margin:0}", "") # remove outlook styles
body&.gsub!("\0", '') # remove null characters
body = body&.strip

return unless body.present?
Expand Down Expand Up @@ -361,6 +363,7 @@ def clean_html_version(html)
html&.gsub!(/<div style="display:none;border:0px;width:0px;height:0px;overflow:hidden;">.+<\/div>/, "") # remove hidden divs / tracking pixels
html&.gsub!(/src=\"cid\:\S+\"/, "src=\"\" style=\"display: none;\"") # remove attached images showing as broken inline images
html&.gsub!("p.MsoNormal,p.MsoNoSpacing{margin:0}", "") # remove outlook styles
html&.gsub!("\0", '') # remove null characters

empty_line_regex = /(<div>\n<div>\z)|(<br\s*\/?>\z)|(\n\z)/
while html&.match?(empty_line_regex)
Expand Down

0 comments on commit e51095e

Please sign in to comment.