Skip to content

Commit

Permalink
Use node email sig strip
Browse files Browse the repository at this point in the history
Python deps are too complicated
Refs #826
  • Loading branch information
nikolai-b committed Dec 14, 2018
1 parent a43bddb commit d380276
Show file tree
Hide file tree
Showing 7 changed files with 705 additions and 89 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
# In many cases you can simplify this from what is generated here.
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- run: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
- run: sudo apt-get install -y nodejs
- run: sudo npm install -g [email protected]
# Dependencies
# This would typically go in either a build or a build-and-test job when using workflows
# Restore the dependency cache
Expand Down
4 changes: 2 additions & 2 deletions app/models/message_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def add_messages_from_email!(mail, in_reply_to)

text = if mail.message.html_part
# For multipart messages we pull out the html part content and use python to remove the signature
body = %x(./lib/sig_strip.py #{Shellwords.escape(mail.message.html_part.decoded)})
body.gsub(%r{(</?html>|</?body>|</?head>)},"")
body = %x(./lib/sig_strip.js #{Shellwords.escape(mail.message.html_part.decoded)})
body.gsub(%r{(</?html>|</?body>|</?head>|\r)},"")
else
# When there is no HTML we get the text part or just the message and use EmailReplyParser to remove the signature
body = (mail.message.text_part || mail.message).decoded
Expand Down
6 changes: 6 additions & 0 deletions lib/sig_strip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

const planer = require('planer')
const jsdom = require('jsdom')
const dom = new jsdom.JSDOM().window.document
console.log(planer.extractFrom(process.argv[2], 'text/html', dom))
10 changes: 0 additions & 10 deletions lib/sig_strip.py

This file was deleted.

Loading

1 comment on commit d380276

@mvl22
Copy link
Member

@mvl22 mvl22 commented on d380276 Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done for pursuing this. This stuff is all horrid of course!

Please sign in to comment.