fix: delete PDF download links at submit mail and added PDF download defense handling
This commit is contained in:
parent
2bb4d26496
commit
8001a027ef
@ -277,9 +277,12 @@ export class SurveySalesService {
|
||||
* @returns {Promise<Blob>} PDF Blob
|
||||
*/
|
||||
async createSurveyPdf(survey: SurveyBasicInfo): Promise<Blob | ApiError> {
|
||||
const convertedSurvey = convertToCamelCase(survey) as SurveyBasicInfo
|
||||
const content = React.createElement(Document, null, React.createElement(SurveySalePdf, { survey: convertedSurvey }))
|
||||
if (!survey) {
|
||||
return new ApiError(HttpStatusCode.NotFound, ERROR_MESSAGE.NOT_FOUND)
|
||||
}
|
||||
try {
|
||||
const convertedSurvey = convertToCamelCase(survey) as SurveyBasicInfo
|
||||
const content = React.createElement(Document, null, React.createElement(SurveySalePdf, { survey: convertedSurvey }))
|
||||
const pdfBlob = await pdf(content).toBlob()
|
||||
const arrayBuffer = await pdfBlob.arrayBuffer()
|
||||
return new Blob([arrayBuffer], { type: 'application/pdf' })
|
||||
@ -427,9 +430,7 @@ export class SurveySalesService {
|
||||
private checkAdminSubRole(survey: any, storeId: string | null, storeNm: string | null): boolean {
|
||||
if (!storeId) return false
|
||||
return survey.SUBMISSION_STATUS
|
||||
? survey.SUBMISSION_TARGET_ID === storeId ||
|
||||
survey.SUBMISSION_TARGET_NM === storeNm ||
|
||||
survey.STORE_ID === storeId
|
||||
? survey.SUBMISSION_TARGET_ID === storeId || survey.SUBMISSION_TARGET_NM === storeNm || survey.STORE_ID === storeId
|
||||
: survey.STORE_ID === storeId
|
||||
}
|
||||
|
||||
|
||||
@ -183,18 +183,6 @@ export default function SurveySaleSubmitPopup() {
|
||||
-施工店名:
|
||||
<span style="color: #417DDC;">${surveyDetail?.constructionPoint ?? ' - '}</span>
|
||||
</p>
|
||||
<p>
|
||||
<a
|
||||
style="font-size: 13px; font-weight: 400; color: #1259CB; margin-bottom: 5px; text-decoration: underline;"
|
||||
href="${process.env.NEXT_PUBLIC_API_URL}/api/survey-sales/${surveyDetail?.id}?isPdf=true"
|
||||
target="_blank"
|
||||
>
|
||||
現地調査結果PDFダウンロード
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 13px; font-weight: 400; color: #2e3a59;">
|
||||
※リンクをクリックしてローカル調査結果PDFをダウンロードできます。
|
||||
</p>
|
||||
</div>
|
||||
`
|
||||
|
||||
|
||||
@ -31,17 +31,38 @@ export async function sendEmail({ from, to, cc, subject, content, attachments, s
|
||||
*/
|
||||
let surveyPdfBuffer: Buffer | null = null
|
||||
if (surveyPdf) {
|
||||
const resp = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/survey-sales/${surveyPdf.id}?isPdf=true`, {
|
||||
const resp = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/survey-sales/${0}?isPdf=true`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/pdf',
|
||||
},
|
||||
})
|
||||
const pdfBlob = await resp.blob()
|
||||
surveyPdfBuffer = Buffer.from(await pdfBlob.arrayBuffer())
|
||||
if (resp.status == 200) {
|
||||
const pdfBlob = await resp.blob()
|
||||
surveyPdfBuffer = Buffer.from(await pdfBlob.arrayBuffer())
|
||||
}
|
||||
}
|
||||
const surveyPdfAttachment = surveyPdfBuffer ? [{ filename: '[HANASYS現地調査]' + surveyPdf?.filename + '.pdf', content: surveyPdfBuffer }] : []
|
||||
|
||||
if (!surveyPdfBuffer && surveyPdf) {
|
||||
content += `
|
||||
<div>
|
||||
<p>
|
||||
<a
|
||||
style="font-size: 13px; font-weight: 400; color: #1259CB; margin-bottom: 5px; text-decoration: underline;"
|
||||
href="${process.env.NEXT_PUBLIC_API_URL}/api/survey-sales/${surveyPdf.id}?isPdf=true"
|
||||
target="_blank"
|
||||
>
|
||||
現地調査結果PDFダウンロード
|
||||
</a>
|
||||
</p>
|
||||
<p style="font-size: 13px; font-weight: 400; color: #2e3a59;">
|
||||
※リンクをクリックしてローカル調査結果PDFをダウンロードできます。
|
||||
</p>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
/**
|
||||
* @description SMTP 트랜스포터 생성
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user