Skip to content

Commit

Permalink
Merge branch 'next' into feat/auto-import-ui-revision
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismayuresh authored Dec 23, 2024
2 parents 4ec2ebe + e333f5c commit 89d7e71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { FileMimeTypesEnum } from '@impler/shared';
import { isValidXMLMimeType } from '@shared/helpers/common.helper';
import { APIMessages } from '@shared/constants';
import { UserJobEntity, UserJobRepository } from '@impler/dal';
import { RSSService } from '@shared/services';
Expand All @@ -20,7 +20,7 @@ export class CreateUserJob {
authHeaderValue,
}: CreateUserJobCommand): Promise<UserJobEntity> {
const mimeType = await this.rssService.getMimeType(url);
if (mimeType === FileMimeTypesEnum.XML || mimeType === FileMimeTypesEnum.TEXTXML) {
if (isValidXMLMimeType(mimeType)) {
const { rssKeyHeading } = await this.rssService.parseRssFeed(url);
let formattedExtra = extra || '{}';
try {
Expand Down
12 changes: 12 additions & 0 deletions apps/api/src/app/shared/helpers/common.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ export function captureException(error: any) {
Sentry.captureException(error);
} else console.error(error);
}

export function isValidXMLMimeType(mimeType: string): boolean {
if (
mimeType === FileMimeTypesEnum.XML ||
mimeType === FileMimeTypesEnum.TEXTXML ||
mimeType === FileMimeTypesEnum.APPLICATION_XML
) {
return true;
}

return false;
}
1 change: 1 addition & 0 deletions libs/shared/src/types/upload/upload.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum FileMimeTypesEnum {
'EXCELM' = 'application/vnd.ms-excel.sheet.macroenabled.12',
'JSON' = 'application/json',
'XML' = 'application/rss+xml',
'APPLICATION_XML' = 'application/xml',
'TEXTXML' = 'text/xml',
'PNG' = 'image/png',
'JPG' = 'image/jpeg',
Expand Down

0 comments on commit 89d7e71

Please sign in to comment.