fix(server): add missing avi mime types and add tests (#3001)

See https://github.com/immich-app/immich/pull/2952#pullrequestreview-1497194041

Fixes: #2975
This commit is contained in:
Thomas
2023-06-28 15:21:42 +01:00
committed by GitHub
parent e98398cab8
commit 792ecc6cac
5 changed files with 83 additions and 87 deletions

View File

@@ -0,0 +1,21 @@
import { validMimeTypes } from './domain.constant';
describe('valid mime types', () => {
it('should be a sorted list', () => {
expect(validMimeTypes).toEqual(validMimeTypes.sort());
});
it('should contain only unique values', () => {
expect(validMimeTypes).toEqual([...new Set(validMimeTypes)]);
});
it('should contain only image or video mime types', () => {
expect(validMimeTypes).toEqual(
validMimeTypes.filter((mimeType) => mimeType.startsWith('image/') || mimeType.startsWith('video/')),
);
});
it('should contain only lowercase mime types', () => {
expect(validMimeTypes).toEqual(validMimeTypes.map((mimeType) => mimeType.toLowerCase()));
});
});

View File

@@ -28,16 +28,40 @@ export function assertMachineLearningEnabled() {
}
}
const validMimeTypes = [
export const validMimeTypes = [
'image/3fr',
'image/ari',
'image/arw',
'image/avif',
'image/cap',
'image/cin',
'image/cr2',
'image/cr3',
'image/crw',
'image/dcr',
'image/dng',
'image/erf',
'image/fff',
'image/gif',
'image/heic',
'image/heif',
'image/iiq',
'image/jpeg',
'image/jxl',
'image/k25',
'image/kdc',
'image/mrw',
'image/nef',
'image/orf',
'image/ori',
'image/pef',
'image/png',
'image/dng',
'image/raf',
'image/raw',
'image/rwl',
'image/sr2',
'image/srf',
'image/srw',
'image/tiff',
'image/webp',
'image/x-adobe-dng',
@@ -67,38 +91,15 @@ const validMimeTypes = [
'image/x-sony-arw',
'image/x-sony-sr2',
'image/x-sony-srf',
'image/dng',
'image/ari',
'image/cr2',
'image/cr3',
'image/crw',
'image/erf',
'image/raf',
'image/3fr',
'image/fff',
'image/dcr',
'image/k25',
'image/kdc',
'image/rwl',
'image/mrw',
'image/nef',
'image/orf',
'image/ori',
'image/raw',
'image/pef',
'image/cin',
'image/cap',
'image/iiq',
'image/srw',
'image/x3f',
'image/arw',
'image/sr2',
'image/srf',
'video/3gpp',
'video/avi',
'video/mp2t',
'video/mp4',
'video/mpeg',
'video/msvideo',
'video/quicktime',
'video/vnd.avi',
'video/webm',
'video/x-flv',
'video/x-matroska',