| Conditions | 2 |
| Paths | 1 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import path from 'path' |
||
| 8 | const sendRawEmail = (req, res, dateDir, fullDir, log) => { |
||
| 9 | if (!req.body['RawMessage.Data']) { |
||
| 10 | throw new Error('RawMessage.Data is required and was not sent') |
||
| 11 | } |
||
| 12 | |||
| 13 | mkdir(path.join(dateDir)) |
||
| 14 | mkdir(path.join(fullDir)) |
||
| 15 | log(` 🍣 ${chalk.green('Raw Email Received')} |
||
| 16 | ${chalk.blue('From:')} ${req.body.Source} |
||
| 17 | ${chalk.blue('To:')} ${req.body['Destinations.member.1']} |
||
| 18 | ${chalk.blue('Raw Message:')} ${process.cwd()}/${path.join(fullDir)}/raw-message |
||
| 19 | `) |
||
| 20 | const decodedBody = Buffer.from(req.body['RawMessage.Data'], 'base64').toString() |
||
|
|
|||
| 21 | fs.writeFileSync(`${fullDir}/raw-message`, decodedBody) |
||
| 22 | |||
| 23 | res.status(200).send( |
||
| 24 | successTemplate.replace('{{message}}', `${process.cwd()}/${path.join(fullDir)}/raw-message`) |
||
| 25 | ) |
||
| 26 | } |
||
| 27 | |||
| 28 | module.exports = sendRawEmail |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.