-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: notifyEmailFailureToReportChannel
- Loading branch information
1 parent
e541fc0
commit a526443
Showing
2 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const nodemailer = require("nodemailer"); | ||
const logger = require("./logger"); | ||
const { nodeEnv } = require("../../loadenv"); | ||
const { notifyEmailFailureToReportChannel } = require("../modules/slackNotification"); | ||
|
||
/** | ||
* production 환경에서 메일을 전송하기 위해 사용되는 agent입니다. | ||
|
@@ -32,7 +33,7 @@ class NodemailerTransport { | |
return true; | ||
} catch (err) { | ||
logger.error(`Failed to send email: ${err}`); | ||
return false; | ||
return err; | ||
} | ||
} | ||
} | ||
|
@@ -103,7 +104,7 @@ class MockNodemailerTransport { | |
return true; | ||
} catch (err) { | ||
logger.error(`Failed to send email: ${err}`); | ||
return false; | ||
return err; | ||
} | ||
} | ||
} | ||
|
@@ -129,15 +130,21 @@ const sendReportEmail = async (reportedEmail, report, html) => { | |
"etc-reason": "기타 사유", | ||
}; | ||
|
||
return transporter.sendMail({ | ||
const mailOptions = { | ||
from: "[email protected]", | ||
to: reportedEmail, | ||
subject: `[SPARCS TAXI] 신고가 접수되었습니다 (사유: ${ | ||
reportTypeMap[report.type] | ||
})`, | ||
html, | ||
}); | ||
}; | ||
} | ||
|
||
const result = await transporter.sendMail(mailOptions); | ||
|
||
if (result instanceof Error) { | ||
notifyEmailFailureToReportChannel(mailOptions, report, result); | ||
} | ||
} | ||
|
||
module.exports = { | ||
sendReportEmail, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters