Skip to content

Commit

Permalink
Stripe signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Jan 8, 2024
1 parent c74a02e commit 4406087
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ def initialize(email)
@attachments = email.attachments
@user = find_user_from_user_key(@token, @from)

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

@inbound_email_params = {
subject: to_utf8(email.subject),
cc: email.cc,
Expand Down Expand Up @@ -335,14 +327,14 @@ def clean_html_version(html)
html&.gsub!("<html>", "")&.gsub!("</html>", "")&.gsub!("<body>", "")&.gsub!("</body>", "")&.gsub!("<head>", "")&.gsub!("</head>", "")

html = Rinku.auto_link(html, :all, 'target="_blank"')
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 = ActionController::Base.helpers.sanitize(html, tags: %w(strong em a div span ul ol li b i br p hr u em blockquote), attributes: %w(href target))
html = html.split("<br>--<br>").first # strip out gmail signature
html = html.split("<div><br></div>\n<div>--</div>").first # strip out gmail signature
html = html.split("<br>--").first # strip out gmail signature
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

0 comments on commit 4406087

Please sign in to comment.