diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-06 12:26:58 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-06 12:26:58 +0100 |
commit | 73471b1a52f242e86364ffb077ea6cadb3b07ae2 (patch) | |
tree | 43dbb7748e281f8d80f15326f489cdea10ec857d /shared/utils/miscs/email-child-process.js | |
parent | c22419dd265c0c7185bf4197a1cb286eb3d8ebc0 (diff) | |
parent | f5305c04aae14467d6f957b713c5a902275cbb89 (diff) | |
download | PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.tar.gz PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.tar.zst PeerTube-73471b1a52f242e86364ffb077ea6cadb3b07ae2.zip |
Merge branch 'release/v1.2.0'
Diffstat (limited to 'shared/utils/miscs/email-child-process.js')
-rw-r--r-- | shared/utils/miscs/email-child-process.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/shared/utils/miscs/email-child-process.js b/shared/utils/miscs/email-child-process.js new file mode 100644 index 000000000..40ae37d70 --- /dev/null +++ b/shared/utils/miscs/email-child-process.js | |||
@@ -0,0 +1,27 @@ | |||
1 | const MailDev = require('maildev') | ||
2 | |||
3 | // must run maildev as forked ChildProcess | ||
4 | // failed instantiation stops main process with exit code 0 | ||
5 | process.on('message', (msg) => { | ||
6 | if (msg.start) { | ||
7 | const maildev = new MailDev({ | ||
8 | ip: '127.0.0.1', | ||
9 | smtp: 1025, | ||
10 | disableWeb: true, | ||
11 | silent: true | ||
12 | }) | ||
13 | |||
14 | maildev.on('new', email => { | ||
15 | process.send({ email }) | ||
16 | }) | ||
17 | |||
18 | maildev.listen(err => { | ||
19 | if (err) { | ||
20 | // cannot send as Error object | ||
21 | return process.send({ err: err.message }) | ||
22 | } | ||
23 | |||
24 | return process.send({ err: null }) | ||
25 | }) | ||
26 | } | ||
27 | }) | ||