Skip to content

Commit

Permalink
Merge pull request #3426 from GovAlta/CS-3524
Browse files Browse the repository at this point in the history
fix(CS-3525) - Forcing file extension to be PDF on generation
  • Loading branch information
jonathanweyermann authored Sep 13, 2024
2 parents 3943cd7 + 13c54f7 commit 88b260b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions apps/pdf-service/src/pdf/job/generate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
AdspId,
ConfigurationService,
EventService,
TokenProvider,
} from '@abgov/adsp-service-sdk';
import { AdspId, ConfigurationService, EventService, TokenProvider } from '@abgov/adsp-service-sdk';
import { NotFoundError } from '@core-services/core-common';
import { Logger } from 'winston';
import { pdfGenerated, pdfGenerationFailed } from '../events';
Expand Down Expand Up @@ -37,7 +32,8 @@ export function createGenerateJob({
retryOnError: boolean,
done: (err?: Error) => void
): Promise<void> => {
logger.info(`Starting generation of PDF (ID: ${jobId}) file: ${filename}...`, {
const pdfFilename = filename = filename.replace(/\.[^/.]+$/, "") + ".pdf";
logger.info(`Starting generation of PDF (ID: ${jobId}) file: ${pdfFilename}...`, {
context,
tenant: tenantIdValue,
});
Expand All @@ -64,11 +60,11 @@ export function createGenerateJob({
tenant: tenantId?.toString(),
});

const result = await fileService.upload(tenantId, fileType, recordId, filename, pdf);
const result = await fileService.upload(tenantId, fileType, recordId, pdfFilename, pdf);

eventService.send(pdfGenerated(tenantId, jobId, templateId, result, requestedBy));

logger.info(`Generated PDF (ID: ${jobId}) file ${filename} and uploaded to file service at: ${result.urn}`, {
logger.info(`Generated PDF (ID: ${jobId}) file ${pdfFilename} and uploaded to file service at: ${result.urn}`, {
context,
tenant: tenantId?.toString(),
});
Expand Down

0 comments on commit 88b260b

Please sign in to comment.