Skip to content

Commit

Permalink
fix: dedupe SMTP recipients before send
Browse files Browse the repository at this point in the history
Closes eleith#242.
  • Loading branch information
zypA13510 committed Oct 9, 2019
1 parent a16e200 commit a16903e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"Hiverness",
"mscdex",
"jimmybergman",
"zackschuster"
"zackschuster",
"Yuping Zuo (https:/zypA13510)"
],
"repository": {
"type": "git",
"url": "http:/eleith/emailjs.git"
},
"dependencies": {
"addressparser": "^0.3.2",
"emailjs-mime-codec": "^2.0.7"
"emailjs-mime-codec": "^2.0.7",
"lodash.unionwith": "^4.6.0"
},
"devDependencies": {
"chai": "^4.1.2",
Expand All @@ -37,8 +39,8 @@
],
"main": "email.js",
"scripts": {
"rollup": "rollup -c rollup.config.js && npm run rollup:test",
"rollup:test": "npm run test -- --file rollup/email.bundle.test.js",
"rollup": "rollup -c rollup.config.js && npm run rollup:test",
"rollup:test": "npm run test -- --file rollup/email.bundle.test.js",
"test": "mocha"
},
"license": "MIT",
Expand Down
7 changes: 5 additions & 2 deletions smtp/client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { SMTP, state } = require('./smtp');
const { Message, create } = require('./message');
const addressparser = require('addressparser');
const _ = {
unionWith: require('lodash.unionwith'),
};

class Client {
/**
Expand Down Expand Up @@ -95,11 +98,11 @@ class Client {
};

if (message.header.cc) {
stack.to = stack.to.concat(addressparser(message.header.cc));
stack.to = _.unionWith(stack.to, addressparser(message.header.cc), (x, y) => x.address === y.address);
}

if (message.header.bcc) {
stack.to = stack.to.concat(addressparser(message.header.bcc));
stack.to = _.unionWith(stack.to, addressparser(message.header.bcc), (x, y) => x.address === y.address);
}

if (
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,11 @@ [email protected]:
dependencies:
uc.micro "^1.0.1"

lodash.unionwith@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.unionwith/-/lodash.unionwith-4.6.0.tgz#74d140b5ca8146e6c643c3724f5152538d9ac1f0"
integrity sha1-dNFAtcqBRubGQ8NyT1FSU42awfA=

lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
Expand Down

0 comments on commit a16903e

Please sign in to comment.