diff options
Diffstat (limited to 'lib/rfq-last/approval-actions.ts')
| -rw-r--r-- | lib/rfq-last/approval-actions.ts | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/rfq-last/approval-actions.ts b/lib/rfq-last/approval-actions.ts index be435931..2f9d0843 100644 --- a/lib/rfq-last/approval-actions.ts +++ b/lib/rfq-last/approval-actions.ts @@ -8,6 +8,7 @@ import { ApprovalSubmissionSaga } from '@/lib/approval'; import { mapRfqSendToTemplateVariables } from './approval-handlers'; +import { prepareEmailAttachments } from './service'; interface RfqSendApprovalData { // RFQ 기본 정보 @@ -95,7 +96,27 @@ export async function requestRfqSendWithApproval(data: RfqSendApprovalData) { applicationReason: data.applicationReason, }); - // 3. 결재 상신용 payload 구성 + // 3. Knox 상신용 첨부파일 준비 (실제 파일 객체로 변환) + const emailAttachments = await prepareEmailAttachments(data.rfqId, data.attachmentIds); + type PreparedAttachment = { + filename?: string | null; + content: BlobPart; + contentType?: string | null; + }; + const knoxAttachments = (emailAttachments as PreparedAttachment[]) + .filter((att): att is PreparedAttachment => Boolean(att && att.content)) + .map( + (att) => + new File([att.content], att.filename || 'attachment', { + type: att.contentType || 'application/octet-stream', + }) + ); + + if (knoxAttachments.length === 0) { + throw new Error('상신할 첨부파일을 준비하지 못했습니다.'); + } + + // 4. 결재 상신용 payload 구성 // ⚠️ cronjob 환경에서 실행되므로 currentUser 정보를 포함해야 함 const approvalPayload = { rfqId: data.rfqId, @@ -113,7 +134,7 @@ export async function requestRfqSendWithApproval(data: RfqSendApprovalData) { }, }; - // 4. Saga로 결재 상신 + // 5. Saga로 결재 상신 const saga = new ApprovalSubmissionSaga( 'rfq_send_with_attachments', // 핸들러 키 approvalPayload, // 결재 승인 후 실행될 데이터 @@ -128,6 +149,7 @@ export async function requestRfqSendWithApproval(data: RfqSendApprovalData) { epId: data.currentUser.epId, email: data.currentUser.email, }, + attachments: knoxAttachments, } ); |
