fix: delete PDF download links at submit mail and added PDF download defense handling

This commit is contained in:
Dayoung 2025-07-08 14:16:44 +09:00
parent 2bb4d26496
commit 8001a027ef
3 changed files with 30 additions and 20 deletions

View File

@ -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
}

View File

@ -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>
`

View File

@ -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
*/