mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
b0af770cf3
Summary: - Remove thread_participants prop, we don't use them anywhere and the underscore-case is ugly. - Move autolinker into extension, update autolinker to 0.18.1 for phone number support - document message.coffee, add isFromMe() - Add tracking pixel extension that removes pixels from mail you *send*. Maybe more features later. Test Plan: Run 1 new test! (woo...) Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1787
122 lines
3.2 KiB
CoffeeScript
122 lines
3.2 KiB
CoffeeScript
{MessageStoreExtension, RegExpUtils} = require 'nylas-exports'
|
|
|
|
TrackingBlacklist = [{
|
|
name: 'Sidekick',
|
|
pattern: 't.signaux',
|
|
homepage: 'http://getsidekick.com'
|
|
}, {
|
|
name: 'Sidekick',
|
|
pattern: 't.senal',
|
|
homepage: 'http://getsidekick.com'
|
|
}, {
|
|
name: 'Sidekick',
|
|
pattern: 't.sidekickopen',
|
|
homepage: 'http://getsidekick.com'
|
|
}, {
|
|
name: 'Sidekick',
|
|
pattern: 't.sigopn',
|
|
homepage: 'http://getsidekick.com'
|
|
}, {
|
|
name: 'Banana Tag',
|
|
pattern: 'bl-1.com',
|
|
homepage: 'http://bananatag.com'
|
|
}, {
|
|
name: 'Boomerang',
|
|
pattern: 'mailstat.us/tr',
|
|
homepage: 'http://boomeranggmail.com'
|
|
}, {
|
|
name: 'Cirrus Inisght',
|
|
pattern: 'tracking.cirrusinsight.com',
|
|
homepage: 'http://cirrusinsight.com'
|
|
}, {
|
|
name: 'Yesware',
|
|
pattern: 'app.yesware.com',
|
|
homepage: 'http://yesware.com'
|
|
}, {
|
|
name: 'Yesware',
|
|
pattern: 't.yesware.com',
|
|
homepage: 'http://yesware.com'
|
|
}, {
|
|
name: 'Streak',
|
|
pattern: 'mailfoogae.appspot.com',
|
|
homepage: 'http://streak.com'
|
|
}, {
|
|
name: 'LaunchBit',
|
|
pattern: 'launchbit.com/taz-pixel',
|
|
homepage: 'http://launchbit.com'
|
|
}, {
|
|
name: 'MailChimp',
|
|
pattern: 'list-manage.com/track',
|
|
homepage: 'http://mailchimp.com'
|
|
}, {
|
|
name: 'Postmark',
|
|
pattern: 'cmail1.com/t',
|
|
homepage: 'http://postmarkapp.com'
|
|
}, {
|
|
name: 'iContact',
|
|
pattern: 'click.icptrack.com/icp/',
|
|
homepage: 'http://icontact.com'
|
|
}, {
|
|
name: 'Infusionsoft',
|
|
pattern: 'infusionsoft.com/app/emailOpened',
|
|
homepage: 'http://infusionsoft.com'
|
|
}, {
|
|
name: 'Intercom',
|
|
pattern: 'via.intercom.io/o',
|
|
homepage: 'http://intercom.io'
|
|
}, {
|
|
name: 'Mandrill',
|
|
pattern: 'mandrillapp.com/track',
|
|
homepage: 'http://mandrillapp.com'
|
|
}, {
|
|
name: 'Hubspot',
|
|
pattern: 't.hsms06.com',
|
|
homepage: 'http://hubspot.com'
|
|
}, {
|
|
name: 'RelateIQ',
|
|
pattern: 'app.relateiq.com/t.png',
|
|
homepage: 'http://relateiq.com'
|
|
}, {
|
|
name: 'RJ Metrics',
|
|
pattern: 'go.rjmetrics.com',
|
|
homepage: 'http://rjmetrics.com'
|
|
}, {
|
|
name: 'Mixpanel',
|
|
pattern: 'api.mixpanel.com/track',
|
|
homepage: 'http://mixpanel.com'
|
|
}, {
|
|
name: 'Front App',
|
|
pattern: 'web.frontapp.com/api',
|
|
homepage: 'http://frontapp.com'
|
|
}, {
|
|
name: 'Mailtrack.io',
|
|
pattern: 'mailtrack.io/trace',
|
|
homepage: 'http://mailtrack.io'
|
|
}, {
|
|
name: 'Salesloft',
|
|
pattern: 'sdr.salesloft.com/email_trackers',
|
|
homepage: 'http://salesloft.com'
|
|
}]
|
|
|
|
class TrackingPixelsExtension extends MessageStoreExtension
|
|
|
|
@formatMessageBody: (message) ->
|
|
return unless message.isFromMe()
|
|
|
|
regex = RegExpUtils.imageTagRegex()
|
|
body = message.body
|
|
spliceRegions = []
|
|
|
|
# Identify img tags that should be cut out
|
|
while (result = regex.exec(body)) isnt null
|
|
for item in TrackingBlacklist
|
|
if result[1].indexOf(item.pattern) > 0
|
|
spliceRegions.push(start: result.index, end: result.index + result[0].length)
|
|
continue
|
|
|
|
# Remove them all, from the end of the string to the start
|
|
spliceRegions.reverse().forEach ({start, end}) ->
|
|
body = body.substr(0, start) + body.substr(end)
|
|
message.body = body
|
|
|
|
module.exports = TrackingPixelsExtension
|