-
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.
Browse files
Browse the repository at this point in the history
#303 introduce aws ses
- Loading branch information
Showing
17 changed files
with
277 additions
and
89 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { slackWebhookUrl: slackUrl } = require("../../loadenv"); | ||
const axios = require("axios"); | ||
const logger = require("../modules/logger"); | ||
|
||
module.exports.notifyToReportChannel = (reportUser, report) => { | ||
if (!slackUrl.report) return; | ||
|
||
const data = { | ||
text: `${reportUser}님으로부터 신고가 접수되었습니다. | ||
신고자 ID: ${report.creatorId} | ||
신고 ID: ${report.reportedId} | ||
방 ID: ${report.roomId ?? ""} | ||
사유: ${report.type} | ||
기타: ${report.etcDetail} | ||
`, | ||
}; | ||
const config = { "Content-Type": "application/json" }; | ||
|
||
axios | ||
.post(slackUrl.report, data, config) | ||
.then((res) => { | ||
logger.info("Slack webhook sent successfully"); | ||
}) | ||
.catch((err) => { | ||
logger.error("Fail to send slack webhook", err); | ||
}); | ||
}; |
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
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,12 +1,15 @@ | ||
const { aws: awsEnv } = require("../../../loadenv"); | ||
|
||
const logger = require("../logger"); | ||
// Load the AWS-SDK and s3 | ||
const AWS = require("aws-sdk"); | ||
AWS.config.update({ | ||
region: "ap-northeast-2", | ||
signatureVersion: "v4", | ||
}); | ||
|
||
const s3 = new AWS.S3({ apiVersion: "2006-03-01" }); | ||
const ses = new AWS.SES({ apiVersion: "2010-12-01" }); | ||
|
||
// function to list Object | ||
module.exports.getList = (directoryPath, cb) => { | ||
|
@@ -80,3 +83,37 @@ module.exports.foundObject = (filePath, cb) => { | |
module.exports.getS3Url = (filePath) => { | ||
return `${awsEnv.s3Url}${filePath}`; | ||
}; | ||
|
||
module.exports.sendReportEmail = (reportedEmail, report, html) => { | ||
const reportTypeMap = { | ||
"no-settlement": "정산을 하지 않음", | ||
"no-show": "택시에 동승하지 않음", | ||
"etc-reason": "기타 사유", | ||
}; | ||
|
||
const params = { | ||
Destination: { | ||
ToAddresses: [reportedEmail], | ||
}, | ||
Message: { | ||
Body: { | ||
Html: { | ||
Data: html, | ||
}, | ||
}, | ||
Subject: { | ||
Charset: "UTF-8", | ||
Data: `[SPARCS TAXI] 신고가 접수되었습니다 (사유: ${reportTypeMap[report.type]})`, | ||
}, | ||
}, | ||
Source: "[email protected]", | ||
}; | ||
|
||
ses.sendEmail(params, (err, data) => { | ||
if (err) { | ||
logger.error("Fail to send email", err); | ||
} else { | ||
logger.info("Email sent successfully"); | ||
} | ||
}); | ||
}; |
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
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
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
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
Oops, something went wrong.