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
|
* @returns {Promise<Blob>} PDF Blob
|
||||||
*/
|
*/
|
||||||
async createSurveyPdf(survey: SurveyBasicInfo): Promise<Blob | ApiError> {
|
async createSurveyPdf(survey: SurveyBasicInfo): Promise<Blob | ApiError> {
|
||||||
const convertedSurvey = convertToCamelCase(survey) as SurveyBasicInfo
|
if (!survey) {
|
||||||
const content = React.createElement(Document, null, React.createElement(SurveySalePdf, { survey: convertedSurvey }))
|
return new ApiError(HttpStatusCode.NotFound, ERROR_MESSAGE.NOT_FOUND)
|
||||||
|
}
|
||||||
try {
|
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 pdfBlob = await pdf(content).toBlob()
|
||||||
const arrayBuffer = await pdfBlob.arrayBuffer()
|
const arrayBuffer = await pdfBlob.arrayBuffer()
|
||||||
return new Blob([arrayBuffer], { type: 'application/pdf' })
|
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 {
|
private checkAdminSubRole(survey: any, storeId: string | null, storeNm: string | null): boolean {
|
||||||
if (!storeId) return false
|
if (!storeId) return false
|
||||||
return survey.SUBMISSION_STATUS
|
return survey.SUBMISSION_STATUS
|
||||||
? survey.SUBMISSION_TARGET_ID === storeId ||
|
? survey.SUBMISSION_TARGET_ID === storeId || survey.SUBMISSION_TARGET_NM === storeNm || survey.STORE_ID === storeId
|
||||||
survey.SUBMISSION_TARGET_NM === storeNm ||
|
|
||||||
survey.STORE_ID === storeId
|
|
||||||
: survey.STORE_ID === storeId
|
: survey.STORE_ID === storeId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -183,18 +183,6 @@ export default function SurveySaleSubmitPopup() {
|
|||||||
-施工店名:
|
-施工店名:
|
||||||
<span style="color: #417DDC;">${surveyDetail?.constructionPoint ?? ' - '}</span>
|
<span style="color: #417DDC;">${surveyDetail?.constructionPoint ?? ' - '}</span>
|
||||||
</p>
|
</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>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@ -31,17 +31,38 @@ export async function sendEmail({ from, to, cc, subject, content, attachments, s
|
|||||||
*/
|
*/
|
||||||
let surveyPdfBuffer: Buffer | null = null
|
let surveyPdfBuffer: Buffer | null = null
|
||||||
if (surveyPdf) {
|
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',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/pdf',
|
'Content-Type': 'application/pdf',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const pdfBlob = await resp.blob()
|
if (resp.status == 200) {
|
||||||
surveyPdfBuffer = Buffer.from(await pdfBlob.arrayBuffer())
|
const pdfBlob = await resp.blob()
|
||||||
|
surveyPdfBuffer = Buffer.from(await pdfBlob.arrayBuffer())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const surveyPdfAttachment = surveyPdfBuffer ? [{ filename: '[HANASYS現地調査]' + surveyPdf?.filename + '.pdf', content: surveyPdfBuffer }] : []
|
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 트랜스포터 생성
|
* @description SMTP 트랜스포터 생성
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user