Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Jan 8, 2024
1 parent 2714847 commit 949857d
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ def initialize(email)
@html = clean_html_version(@stripped_html)
@message_id = email.headers&.dig("Message-ID")&.gsub("<", "")&.gsub(">", "")

@raw_body = to_utf8(email.raw_body)
@attachments = email.attachments
@user = find_user_from_user_key(@token, @from)

if @user.id == 1
p "*"*100
p @stripped_html
p "MESSAGE ID"
p email.headers&.dig("Message-ID")
p @message_id
p "*"*100
end

@raw_body = to_utf8(email.raw_body)
@attachments = email.attachments
@user = find_user_from_user_key(@token, @from)

@inbound_email_params = {
subject: to_utf8(email.subject),
cc: email.cc,
Expand Down Expand Up @@ -66,19 +68,7 @@ def process
end
end

if @user.id == 1
p "*"*100
p valid_attachments
p "*"*100
end

if valid_attachments.size > 1
if @user.id == 1
p "*"*100
p "COLLAGING IMAGES FROM MAILGUN"
p "*"*100
end

best_attachment_url = collage_from_mailgun_attachments
elsif valid_attachments.any?
best_attachment = valid_attachments.first
Expand Down Expand Up @@ -348,6 +338,7 @@ def clean_html_version(html)
html = html.split("<br>\n--").first # strip out gmail signature
html = html.split("<br id=\"lineBreakAtBeginningOfSignature\">").first # strip out gmail signature
html = html.split('<br id=\"lineBreakAtBeginningOfSignature\">').first # strip out gmail signature
html = html.split('<br id="lineBreakAtBeginningOfSignature">').first # strip out gmail signature
html&.gsub!(/\A<br\s*\/?>/, "") # remove <br> from very beginning of 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
Expand Down Expand Up @@ -393,12 +384,6 @@ def collage_from_mailgun_attachments
end.compact
return nil unless attachment_urls.any?

if @user.id == 1
p "*"*100
p attachment_urls
p "*"*100
end

collage_from_urls(attachment_urls)
end

Expand Down

0 comments on commit 949857d

Please sign in to comment.