mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 09:15:05 +03:00
refactor: enum casing (#19946)
This commit is contained in:
@@ -11,7 +11,7 @@ export type GrantedRequest = {
|
||||
};
|
||||
|
||||
export const isGranted = ({ requested, current }: GrantedRequest) => {
|
||||
if (current.includes(Permission.ALL)) {
|
||||
if (current.includes(Permission.All)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,36 +63,36 @@ const checkSharedLinkAccess = async (
|
||||
const sharedLinkId = sharedLink.id;
|
||||
|
||||
switch (permission) {
|
||||
case Permission.ASSET_READ: {
|
||||
case Permission.AssetRead: {
|
||||
return await access.asset.checkSharedLinkAccess(sharedLinkId, ids);
|
||||
}
|
||||
|
||||
case Permission.ASSET_VIEW: {
|
||||
case Permission.AssetView: {
|
||||
return await access.asset.checkSharedLinkAccess(sharedLinkId, ids);
|
||||
}
|
||||
|
||||
case Permission.ASSET_DOWNLOAD: {
|
||||
case Permission.AssetDownload: {
|
||||
return sharedLink.allowDownload ? await access.asset.checkSharedLinkAccess(sharedLinkId, ids) : new Set();
|
||||
}
|
||||
|
||||
case Permission.ASSET_UPLOAD: {
|
||||
case Permission.AssetUpload: {
|
||||
return sharedLink.allowUpload ? ids : new Set();
|
||||
}
|
||||
|
||||
case Permission.ASSET_SHARE: {
|
||||
case Permission.AssetShare: {
|
||||
// TODO: fix this to not use sharedLink.userId for access control
|
||||
return await access.asset.checkOwnerAccess(sharedLink.userId, ids, false);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_READ: {
|
||||
case Permission.AlbumRead: {
|
||||
return await access.album.checkSharedLinkAccess(sharedLinkId, ids);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_DOWNLOAD: {
|
||||
case Permission.AlbumDownload: {
|
||||
return sharedLink.allowDownload ? await access.album.checkSharedLinkAccess(sharedLinkId, ids) : new Set();
|
||||
}
|
||||
|
||||
case Permission.ALBUM_ADD_ASSET: {
|
||||
case Permission.AlbumAddAsset: {
|
||||
return sharedLink.allowUpload ? await access.album.checkSharedLinkAccess(sharedLinkId, ids) : new Set();
|
||||
}
|
||||
|
||||
@@ -107,190 +107,190 @@ const checkOtherAccess = async (access: AccessRepository, request: OtherAccessRe
|
||||
|
||||
switch (permission) {
|
||||
// uses album id
|
||||
case Permission.ACTIVITY_CREATE: {
|
||||
case Permission.ActivityCreate: {
|
||||
return await access.activity.checkCreateAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
// uses activity id
|
||||
case Permission.ACTIVITY_DELETE: {
|
||||
case Permission.ActivityDelete: {
|
||||
const isOwner = await access.activity.checkOwnerAccess(auth.user.id, ids);
|
||||
const isAlbumOwner = await access.activity.checkAlbumOwnerAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
return setUnion(isOwner, isAlbumOwner);
|
||||
}
|
||||
|
||||
case Permission.ASSET_READ: {
|
||||
case Permission.AssetRead: {
|
||||
const isOwner = await access.asset.checkOwnerAccess(auth.user.id, ids, auth.session?.hasElevatedPermission);
|
||||
const isAlbum = await access.asset.checkAlbumAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
const isPartner = await access.asset.checkPartnerAccess(auth.user.id, setDifference(ids, isOwner, isAlbum));
|
||||
return setUnion(isOwner, isAlbum, isPartner);
|
||||
}
|
||||
|
||||
case Permission.ASSET_SHARE: {
|
||||
case Permission.AssetShare: {
|
||||
const isOwner = await access.asset.checkOwnerAccess(auth.user.id, ids, false);
|
||||
const isPartner = await access.asset.checkPartnerAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
return setUnion(isOwner, isPartner);
|
||||
}
|
||||
|
||||
case Permission.ASSET_VIEW: {
|
||||
case Permission.AssetView: {
|
||||
const isOwner = await access.asset.checkOwnerAccess(auth.user.id, ids, auth.session?.hasElevatedPermission);
|
||||
const isAlbum = await access.asset.checkAlbumAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
const isPartner = await access.asset.checkPartnerAccess(auth.user.id, setDifference(ids, isOwner, isAlbum));
|
||||
return setUnion(isOwner, isAlbum, isPartner);
|
||||
}
|
||||
|
||||
case Permission.ASSET_DOWNLOAD: {
|
||||
case Permission.AssetDownload: {
|
||||
const isOwner = await access.asset.checkOwnerAccess(auth.user.id, ids, auth.session?.hasElevatedPermission);
|
||||
const isAlbum = await access.asset.checkAlbumAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
const isPartner = await access.asset.checkPartnerAccess(auth.user.id, setDifference(ids, isOwner, isAlbum));
|
||||
return setUnion(isOwner, isAlbum, isPartner);
|
||||
}
|
||||
|
||||
case Permission.ASSET_UPDATE: {
|
||||
case Permission.AssetUpdate: {
|
||||
return await access.asset.checkOwnerAccess(auth.user.id, ids, auth.session?.hasElevatedPermission);
|
||||
}
|
||||
|
||||
case Permission.ASSET_DELETE: {
|
||||
case Permission.AssetDelete: {
|
||||
return await access.asset.checkOwnerAccess(auth.user.id, ids, auth.session?.hasElevatedPermission);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_READ: {
|
||||
case Permission.AlbumRead: {
|
||||
const isOwner = await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
const isShared = await access.album.checkSharedAlbumAccess(
|
||||
auth.user.id,
|
||||
setDifference(ids, isOwner),
|
||||
AlbumUserRole.VIEWER,
|
||||
AlbumUserRole.Viewer,
|
||||
);
|
||||
return setUnion(isOwner, isShared);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_ADD_ASSET: {
|
||||
case Permission.AlbumAddAsset: {
|
||||
const isOwner = await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
const isShared = await access.album.checkSharedAlbumAccess(
|
||||
auth.user.id,
|
||||
setDifference(ids, isOwner),
|
||||
AlbumUserRole.EDITOR,
|
||||
AlbumUserRole.Editor,
|
||||
);
|
||||
return setUnion(isOwner, isShared);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_UPDATE: {
|
||||
case Permission.AlbumUpdate: {
|
||||
return await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_DELETE: {
|
||||
case Permission.AlbumDelete: {
|
||||
return await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_SHARE: {
|
||||
case Permission.AlbumShare: {
|
||||
return await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_DOWNLOAD: {
|
||||
case Permission.AlbumDownload: {
|
||||
const isOwner = await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
const isShared = await access.album.checkSharedAlbumAccess(
|
||||
auth.user.id,
|
||||
setDifference(ids, isOwner),
|
||||
AlbumUserRole.VIEWER,
|
||||
AlbumUserRole.Viewer,
|
||||
);
|
||||
return setUnion(isOwner, isShared);
|
||||
}
|
||||
|
||||
case Permission.ALBUM_REMOVE_ASSET: {
|
||||
case Permission.AlbumRemoveAsset: {
|
||||
const isOwner = await access.album.checkOwnerAccess(auth.user.id, ids);
|
||||
const isShared = await access.album.checkSharedAlbumAccess(
|
||||
auth.user.id,
|
||||
setDifference(ids, isOwner),
|
||||
AlbumUserRole.EDITOR,
|
||||
AlbumUserRole.Editor,
|
||||
);
|
||||
return setUnion(isOwner, isShared);
|
||||
}
|
||||
|
||||
case Permission.ASSET_UPLOAD: {
|
||||
case Permission.AssetUpload: {
|
||||
return ids.has(auth.user.id) ? new Set([auth.user.id]) : new Set<string>();
|
||||
}
|
||||
|
||||
case Permission.ARCHIVE_READ: {
|
||||
case Permission.ArchiveRead: {
|
||||
return ids.has(auth.user.id) ? new Set([auth.user.id]) : new Set();
|
||||
}
|
||||
|
||||
case Permission.AUTH_DEVICE_DELETE: {
|
||||
case Permission.AuthDeviceDelete: {
|
||||
return await access.authDevice.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.FACE_DELETE: {
|
||||
case Permission.FaceDelete: {
|
||||
return access.person.checkFaceOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.NOTIFICATION_READ:
|
||||
case Permission.NOTIFICATION_UPDATE:
|
||||
case Permission.NOTIFICATION_DELETE: {
|
||||
case Permission.NotificationRead:
|
||||
case Permission.NotificationUpdate:
|
||||
case Permission.NotificationDelete: {
|
||||
return access.notification.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.TAG_ASSET:
|
||||
case Permission.TAG_READ:
|
||||
case Permission.TAG_UPDATE:
|
||||
case Permission.TAG_DELETE: {
|
||||
case Permission.TagAsset:
|
||||
case Permission.TagRead:
|
||||
case Permission.TagUpdate:
|
||||
case Permission.TagDelete: {
|
||||
return await access.tag.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.TIMELINE_READ: {
|
||||
case Permission.TimelineRead: {
|
||||
const isOwner = ids.has(auth.user.id) ? new Set([auth.user.id]) : new Set<string>();
|
||||
const isPartner = await access.timeline.checkPartnerAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
return setUnion(isOwner, isPartner);
|
||||
}
|
||||
|
||||
case Permission.TIMELINE_DOWNLOAD: {
|
||||
case Permission.TimelineDownload: {
|
||||
return ids.has(auth.user.id) ? new Set([auth.user.id]) : new Set();
|
||||
}
|
||||
|
||||
case Permission.MEMORY_READ: {
|
||||
case Permission.MemoryRead: {
|
||||
return access.memory.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.MEMORY_UPDATE: {
|
||||
case Permission.MemoryUpdate: {
|
||||
return access.memory.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.MEMORY_DELETE: {
|
||||
case Permission.MemoryDelete: {
|
||||
return access.memory.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.PERSON_CREATE: {
|
||||
case Permission.PersonCreate: {
|
||||
return access.person.checkFaceOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.PERSON_READ:
|
||||
case Permission.PERSON_UPDATE:
|
||||
case Permission.PERSON_DELETE:
|
||||
case Permission.PERSON_MERGE: {
|
||||
case Permission.PersonRead:
|
||||
case Permission.PersonUpdate:
|
||||
case Permission.PersonDelete:
|
||||
case Permission.PersonMerge: {
|
||||
return await access.person.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.PERSON_REASSIGN: {
|
||||
case Permission.PersonReassign: {
|
||||
return access.person.checkFaceOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.PARTNER_UPDATE: {
|
||||
case Permission.PartnerUpdate: {
|
||||
return await access.partner.checkUpdateAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.SESSION_READ:
|
||||
case Permission.SESSION_UPDATE:
|
||||
case Permission.SESSION_DELETE:
|
||||
case Permission.SESSION_LOCK: {
|
||||
case Permission.SessionRead:
|
||||
case Permission.SessionUpdate:
|
||||
case Permission.SessionDelete:
|
||||
case Permission.SessionLock: {
|
||||
return access.session.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.STACK_READ: {
|
||||
case Permission.StackRead: {
|
||||
return access.stack.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.STACK_UPDATE: {
|
||||
case Permission.StackUpdate: {
|
||||
return access.stack.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.STACK_DELETE: {
|
||||
case Permission.StackDelete: {
|
||||
return access.stack.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ export const getAssetFile = (files: AssetFile[], type: AssetFileType | Generated
|
||||
};
|
||||
|
||||
export const getAssetFiles = (files: AssetFile[]) => ({
|
||||
fullsizeFile: getAssetFile(files, AssetFileType.FULLSIZE),
|
||||
previewFile: getAssetFile(files, AssetFileType.PREVIEW),
|
||||
thumbnailFile: getAssetFile(files, AssetFileType.THUMBNAIL),
|
||||
fullsizeFile: getAssetFile(files, AssetFileType.FullSize),
|
||||
previewFile: getAssetFile(files, AssetFileType.Preview),
|
||||
thumbnailFile: getAssetFile(files, AssetFileType.Thumbnail),
|
||||
});
|
||||
|
||||
export const addAssets = async (
|
||||
@@ -33,7 +33,7 @@ export const addAssets = async (
|
||||
const notPresentAssetIds = dto.assetIds.filter((id) => !existingAssetIds.has(id));
|
||||
const allowedAssetIds = await checkAccess(access, {
|
||||
auth,
|
||||
permission: Permission.ASSET_SHARE,
|
||||
permission: Permission.AssetShare,
|
||||
ids: notPresentAssetIds,
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ export const removeAssets = async (
|
||||
const existingAssetIds = await bulk.getAssetIds(dto.parentId, dto.assetIds);
|
||||
const allowedAssetIds = canAlwaysRemove.has(dto.parentId)
|
||||
? existingAssetIds
|
||||
: await checkAccess(access, { auth, permission: Permission.ASSET_SHARE, ids: existingAssetIds });
|
||||
: await checkAccess(access, { auth, permission: Permission.AssetShare, ids: existingAssetIds });
|
||||
|
||||
const results: BulkIdResponseDto[] = [];
|
||||
for (const assetId of dto.assetIds) {
|
||||
@@ -143,15 +143,15 @@ export const onBeforeLink = async (
|
||||
if (!motionAsset) {
|
||||
throw new BadRequestException('Live photo video not found');
|
||||
}
|
||||
if (motionAsset.type !== AssetType.VIDEO) {
|
||||
if (motionAsset.type !== AssetType.Video) {
|
||||
throw new BadRequestException('Live photo video must be a video');
|
||||
}
|
||||
if (motionAsset.ownerId !== userId) {
|
||||
throw new BadRequestException('Live photo video does not belong to the user');
|
||||
}
|
||||
|
||||
if (motionAsset && motionAsset.visibility === AssetVisibility.TIMELINE) {
|
||||
await assetRepository.update({ id: livePhotoVideoId, visibility: AssetVisibility.HIDDEN });
|
||||
if (motionAsset && motionAsset.visibility === AssetVisibility.Timeline) {
|
||||
await assetRepository.update({ id: livePhotoVideoId, visibility: AssetVisibility.Hidden });
|
||||
await eventRepository.emit('AssetHide', { assetId: motionAsset.id, userId });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ export const updateConfig = async (repos: RepoDeps, newConfig: SystemConfig): Pr
|
||||
_.set(partialConfig, property, newValue);
|
||||
}
|
||||
|
||||
await metadataRepo.set(SystemMetadataKey.SYSTEM_CONFIG, partialConfig);
|
||||
await metadataRepo.set(SystemMetadataKey.SystemConfig, partialConfig);
|
||||
|
||||
return getConfig(repos, { withCache: false });
|
||||
};
|
||||
@@ -83,7 +83,7 @@ const buildConfig = async (repos: RepoDeps) => {
|
||||
// load partial
|
||||
const partial = configFile
|
||||
? await loadFromFile(repos, configFile)
|
||||
: await metadataRepo.get(SystemMetadataKey.SYSTEM_CONFIG);
|
||||
: await metadataRepo.get(SystemMetadataKey.SystemConfig);
|
||||
|
||||
// merge with defaults
|
||||
const rawConfig = _.cloneDeep(defaults);
|
||||
|
||||
@@ -154,7 +154,7 @@ export function toJson<DB, TB extends keyof DB & string, T extends TB | Expressi
|
||||
export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_checksum';
|
||||
|
||||
export function withDefaultVisibility<O>(qb: SelectQueryBuilder<DB, 'asset', O>) {
|
||||
return qb.where('asset.visibility', 'in', [sql.lit(AssetVisibility.ARCHIVE), sql.lit(AssetVisibility.TIMELINE)]);
|
||||
return qb.where('asset.visibility', 'in', [sql.lit(AssetVisibility.Archive), sql.lit(AssetVisibility.Timeline)]);
|
||||
}
|
||||
|
||||
// TODO come up with a better query that only selects the fields we need
|
||||
@@ -299,7 +299,7 @@ const joinDeduplicationPlugin = new DeduplicateJoinsPlugin();
|
||||
|
||||
export function searchAssetBuilder(kysely: Kysely<DB>, options: AssetSearchBuilderOptions) {
|
||||
options.withDeleted ||= !!(options.trashedAfter || options.trashedBefore || options.isOffline);
|
||||
const visibility = options.visibility == null ? AssetVisibility.TIMELINE : options.visibility;
|
||||
const visibility = options.visibility == null ? AssetVisibility.Timeline : options.visibility;
|
||||
|
||||
return kysely
|
||||
.withPlugin(joinDeduplicationPlugin)
|
||||
@@ -399,7 +399,7 @@ type VectorIndexQueryOptions = { table: string; vectorExtension: VectorExtension
|
||||
|
||||
export function vectorIndexQuery({ vectorExtension, table, indexName, lists }: VectorIndexQueryOptions): string {
|
||||
switch (vectorExtension) {
|
||||
case DatabaseExtension.VECTORCHORD: {
|
||||
case DatabaseExtension.VectorChord: {
|
||||
return `
|
||||
CREATE INDEX IF NOT EXISTS ${indexName} ON ${table} USING vchordrq (embedding vector_cosine_ops) WITH (options = $$
|
||||
residual_quantization = false
|
||||
@@ -410,7 +410,7 @@ export function vectorIndexQuery({ vectorExtension, table, indexName, lists }: V
|
||||
sampling_factor = 1024
|
||||
$$)`;
|
||||
}
|
||||
case DatabaseExtension.VECTORS: {
|
||||
case DatabaseExtension.Vectors: {
|
||||
return `
|
||||
CREATE INDEX IF NOT EXISTS ${indexName} ON ${table}
|
||||
USING vectors (embedding vector_cos_ops) WITH (options = $$
|
||||
@@ -420,7 +420,7 @@ export function vectorIndexQuery({ vectorExtension, table, indexName, lists }: V
|
||||
ef_construction = 300
|
||||
$$)`;
|
||||
}
|
||||
case DatabaseExtension.VECTOR: {
|
||||
case DatabaseExtension.Vector: {
|
||||
return `
|
||||
CREATE INDEX IF NOT EXISTS ${indexName} ON ${table}
|
||||
USING hnsw (embedding vector_cosine_ops)
|
||||
|
||||
@@ -34,9 +34,9 @@ type SendFile = Parameters<Response['sendFile']>;
|
||||
type SendFileOptions = SendFile[1];
|
||||
|
||||
const cacheControlHeaders: Record<CacheControl, string | null> = {
|
||||
[CacheControl.PRIVATE_WITH_CACHE]: 'private, max-age=86400, no-transform',
|
||||
[CacheControl.PRIVATE_WITHOUT_CACHE]: 'private, no-cache, no-transform',
|
||||
[CacheControl.NONE]: null, // falsy value to prevent adding Cache-Control header
|
||||
[CacheControl.PrivateWithCache]: 'private, max-age=86400, no-transform',
|
||||
[CacheControl.PrivateWithoutCache]: 'private, no-cache, no-transform',
|
||||
[CacheControl.None]: null, // falsy value to prevent adding Cache-Control header
|
||||
};
|
||||
|
||||
export const sendFile = async (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SystemConfigFFmpegDto } from 'src/dtos/system-config.dto';
|
||||
import { CQMode, ToneMapping, TranscodeHWAccel, TranscodeTarget, VideoCodec } from 'src/enum';
|
||||
import { CQMode, ToneMapping, TranscodeHardwareAcceleration, TranscodeTarget, VideoCodec } from 'src/enum';
|
||||
import {
|
||||
AudioStreamInfo,
|
||||
BitrateDistribution,
|
||||
@@ -16,7 +16,7 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
protected constructor(protected config: SystemConfigFFmpegDto) {}
|
||||
|
||||
static create(config: SystemConfigFFmpegDto, interfaces: VideoInterfaces): VideoCodecSWConfig {
|
||||
if (config.accel === TranscodeHWAccel.DISABLED) {
|
||||
if (config.accel === TranscodeHardwareAcceleration.Disabled) {
|
||||
return this.getSWCodecConfig(config);
|
||||
}
|
||||
return this.getHWCodecConfig(config, interfaces);
|
||||
@@ -27,13 +27,13 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
case VideoCodec.H264: {
|
||||
return new H264Config(config);
|
||||
}
|
||||
case VideoCodec.HEVC: {
|
||||
case VideoCodec.Hevc: {
|
||||
return new HEVCConfig(config);
|
||||
}
|
||||
case VideoCodec.VP9: {
|
||||
case VideoCodec.Vp9: {
|
||||
return new VP9Config(config);
|
||||
}
|
||||
case VideoCodec.AV1: {
|
||||
case VideoCodec.Av1: {
|
||||
return new AV1Config(config);
|
||||
}
|
||||
default: {
|
||||
@@ -45,25 +45,25 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
private static getHWCodecConfig(config: SystemConfigFFmpegDto, interfaces: VideoInterfaces) {
|
||||
let handler: VideoCodecHWConfig;
|
||||
switch (config.accel) {
|
||||
case TranscodeHWAccel.NVENC: {
|
||||
case TranscodeHardwareAcceleration.Nvenc: {
|
||||
handler = config.accelDecode
|
||||
? new NvencHwDecodeConfig(config, interfaces)
|
||||
: new NvencSwDecodeConfig(config, interfaces);
|
||||
break;
|
||||
}
|
||||
case TranscodeHWAccel.QSV: {
|
||||
case TranscodeHardwareAcceleration.Qsv: {
|
||||
handler = config.accelDecode
|
||||
? new QsvHwDecodeConfig(config, interfaces)
|
||||
: new QsvSwDecodeConfig(config, interfaces);
|
||||
break;
|
||||
}
|
||||
case TranscodeHWAccel.VAAPI: {
|
||||
case TranscodeHardwareAcceleration.Vaapi: {
|
||||
handler = config.accelDecode
|
||||
? new VaapiHwDecodeConfig(config, interfaces)
|
||||
: new VaapiSwDecodeConfig(config, interfaces);
|
||||
break;
|
||||
}
|
||||
case TranscodeHWAccel.RKMPP: {
|
||||
case TranscodeHardwareAcceleration.Rkmpp: {
|
||||
handler = config.accelDecode
|
||||
? new RkmppHwDecodeConfig(config, interfaces)
|
||||
: new RkmppSwDecodeConfig(config, interfaces);
|
||||
@@ -94,7 +94,7 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
twoPass: this.eligibleForTwoPass(),
|
||||
progress: { frameCount: videoStream.frameCount, percentInterval: 5 },
|
||||
} as TranscodeCommand;
|
||||
if ([TranscodeTarget.ALL, TranscodeTarget.VIDEO].includes(target)) {
|
||||
if ([TranscodeTarget.All, TranscodeTarget.Video].includes(target)) {
|
||||
const filters = this.getFilterOptions(videoStream);
|
||||
if (filters.length > 0) {
|
||||
options.outputOptions.push(`-vf ${filters.join(',')}`);
|
||||
@@ -116,8 +116,8 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
}
|
||||
|
||||
getBaseOutputOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
|
||||
const videoCodec = [TranscodeTarget.ALL, TranscodeTarget.VIDEO].includes(target) ? this.getVideoCodec() : 'copy';
|
||||
const audioCodec = [TranscodeTarget.ALL, TranscodeTarget.AUDIO].includes(target) ? this.getAudioCodec() : 'copy';
|
||||
const videoCodec = [TranscodeTarget.All, TranscodeTarget.Video].includes(target) ? this.getVideoCodec() : 'copy';
|
||||
const audioCodec = [TranscodeTarget.All, TranscodeTarget.Audio].includes(target) ? this.getAudioCodec() : 'copy';
|
||||
|
||||
const options = [
|
||||
`-c:v ${videoCodec}`,
|
||||
@@ -146,7 +146,7 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
}
|
||||
|
||||
if (
|
||||
this.config.targetVideoCodec === VideoCodec.HEVC &&
|
||||
this.config.targetVideoCodec === VideoCodec.Hevc &&
|
||||
(videoCodec !== 'copy' || videoStream.codecName === 'hevc')
|
||||
) {
|
||||
options.push('-tag:v hvc1');
|
||||
@@ -207,7 +207,7 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
}
|
||||
|
||||
eligibleForTwoPass() {
|
||||
if (!this.config.twoPass || this.config.accel !== TranscodeHWAccel.DISABLED) {
|
||||
if (!this.config.twoPass || this.config.accel !== TranscodeHardwareAcceleration.Disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
}
|
||||
|
||||
shouldToneMap(videoStream: VideoStreamInfo) {
|
||||
return videoStream.isHDR && this.config.tonemap !== ToneMapping.DISABLED;
|
||||
return videoStream.isHDR && this.config.tonemap !== ToneMapping.Disabled;
|
||||
}
|
||||
|
||||
getScaling(videoStream: VideoStreamInfo, mult = 2) {
|
||||
@@ -326,7 +326,7 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
}
|
||||
|
||||
useCQP() {
|
||||
return this.config.cqMode === CQMode.CQP;
|
||||
return this.config.cqMode === CQMode.Cqp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ export class BaseHWConfig extends BaseConfig implements VideoCodecHWConfig {
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
return [VideoCodec.H264, VideoCodec.HEVC];
|
||||
return [VideoCodec.H264, VideoCodec.Hevc];
|
||||
}
|
||||
|
||||
validateDevices(devices: string[]) {
|
||||
@@ -526,7 +526,7 @@ export class NvencSwDecodeConfig extends BaseHWConfig {
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
return [VideoCodec.H264, VideoCodec.HEVC, VideoCodec.AV1];
|
||||
return [VideoCodec.H264, VideoCodec.Hevc, VideoCodec.Av1];
|
||||
}
|
||||
|
||||
getBaseInputOptions() {
|
||||
@@ -658,7 +658,7 @@ export class QsvSwDecodeConfig extends BaseHWConfig {
|
||||
getBaseOutputOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
|
||||
const options = super.getBaseOutputOptions(target, videoStream, audioStream);
|
||||
// VP9 requires enabling low power mode https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/33583803e107b6d532def0f9d949364b01b6ad5a
|
||||
if (this.config.targetVideoCodec === VideoCodec.VP9) {
|
||||
if (this.config.targetVideoCodec === VideoCodec.Vp9) {
|
||||
options.push('-low_power 1');
|
||||
}
|
||||
return options;
|
||||
@@ -693,7 +693,7 @@ export class QsvSwDecodeConfig extends BaseHWConfig {
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
return [VideoCodec.H264, VideoCodec.HEVC, VideoCodec.VP9, VideoCodec.AV1];
|
||||
return [VideoCodec.H264, VideoCodec.Hevc, VideoCodec.Vp9, VideoCodec.Av1];
|
||||
}
|
||||
|
||||
// recommended from https://github.com/intel/media-delivery/blob/master/doc/benchmarks/intel-iris-xe-max-graphics/intel-iris-xe-max-graphics.md
|
||||
@@ -712,7 +712,7 @@ export class QsvSwDecodeConfig extends BaseHWConfig {
|
||||
}
|
||||
|
||||
useCQP() {
|
||||
return this.config.cqMode === CQMode.CQP || this.config.targetVideoCodec === VideoCodec.VP9;
|
||||
return this.config.cqMode === CQMode.Cqp || this.config.targetVideoCodec === VideoCodec.Vp9;
|
||||
}
|
||||
|
||||
getScaling(videoStream: VideoStreamInfo): string {
|
||||
@@ -802,7 +802,7 @@ export class VaapiSwDecodeConfig extends BaseHWConfig {
|
||||
const bitrates = this.getBitrateDistribution();
|
||||
const options = [];
|
||||
|
||||
if (this.config.targetVideoCodec === VideoCodec.VP9) {
|
||||
if (this.config.targetVideoCodec === VideoCodec.Vp9) {
|
||||
options.push('-bsf:v vp9_raw_reorder,vp9_superframe');
|
||||
}
|
||||
|
||||
@@ -824,11 +824,11 @@ export class VaapiSwDecodeConfig extends BaseHWConfig {
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
return [VideoCodec.H264, VideoCodec.HEVC, VideoCodec.VP9, VideoCodec.AV1];
|
||||
return [VideoCodec.H264, VideoCodec.Hevc, VideoCodec.Vp9, VideoCodec.Av1];
|
||||
}
|
||||
|
||||
useCQP() {
|
||||
return this.config.cqMode !== CQMode.ICQ || this.config.targetVideoCodec === VideoCodec.VP9;
|
||||
return this.config.cqMode !== CQMode.Icq || this.config.targetVideoCodec === VideoCodec.Vp9;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -900,7 +900,7 @@ export class RkmppSwDecodeConfig extends BaseHWConfig {
|
||||
// from ffmpeg_mpp help, commonly referred to as H264 level 5.1
|
||||
return ['-level 51'];
|
||||
}
|
||||
case VideoCodec.HEVC: {
|
||||
case VideoCodec.Hevc: {
|
||||
// from ffmpeg_mpp help, commonly referred to as HEVC level 5.1
|
||||
return ['-level 153'];
|
||||
}
|
||||
@@ -921,7 +921,7 @@ export class RkmppSwDecodeConfig extends BaseHWConfig {
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
return [VideoCodec.H264, VideoCodec.HEVC];
|
||||
return [VideoCodec.H264, VideoCodec.Hevc];
|
||||
}
|
||||
|
||||
getVideoCodec(): string {
|
||||
|
||||
@@ -129,11 +129,11 @@ export const mimeTypes = {
|
||||
assetType: (filename: string) => {
|
||||
const contentType = lookup(filename);
|
||||
if (contentType.startsWith('image/')) {
|
||||
return AssetType.IMAGE;
|
||||
return AssetType.Image;
|
||||
} else if (contentType.startsWith('video/')) {
|
||||
return AssetType.VIDEO;
|
||||
return AssetType.Video;
|
||||
}
|
||||
return AssetType.OTHER;
|
||||
return AssetType.Other;
|
||||
},
|
||||
getSupportedFileExtensions: () => [...Object.keys(image), ...Object.keys(video)],
|
||||
};
|
||||
|
||||
@@ -234,14 +234,14 @@ export const useSwagger = (app: INestApplication, { write }: { write: boolean })
|
||||
scheme: 'Bearer',
|
||||
in: 'header',
|
||||
})
|
||||
.addCookieAuth(ImmichCookie.ACCESS_TOKEN)
|
||||
.addCookieAuth(ImmichCookie.AccessToken)
|
||||
.addApiKey(
|
||||
{
|
||||
type: 'apiKey',
|
||||
in: 'header',
|
||||
name: ImmichHeader.API_KEY,
|
||||
name: ImmichHeader.ApiKey,
|
||||
},
|
||||
MetadataKey.API_KEY_SECURITY,
|
||||
MetadataKey.ApiKeySecurity,
|
||||
)
|
||||
.addServer('/api')
|
||||
.build();
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getKeysDeep } from 'src/utils/misc';
|
||||
const getDefaultPreferences = (): UserPreferences => {
|
||||
return {
|
||||
albums: {
|
||||
defaultAssetOrder: AssetOrder.DESC,
|
||||
defaultAssetOrder: AssetOrder.Desc,
|
||||
},
|
||||
folders: {
|
||||
enabled: false,
|
||||
@@ -53,7 +53,7 @@ const getDefaultPreferences = (): UserPreferences => {
|
||||
|
||||
export const getPreferences = (metadata: UserMetadataItem[]): UserPreferences => {
|
||||
const preferences = getDefaultPreferences();
|
||||
const item = metadata.find(({ key }) => key === UserMetadataKey.PREFERENCES);
|
||||
const item = metadata.find(({ key }) => key === UserMetadataKey.Preferences);
|
||||
const partial = item?.value || {};
|
||||
for (const property of getKeysDeep(partial)) {
|
||||
_.set(preferences, property, _.get(partial, property));
|
||||
|
||||
@@ -13,13 +13,13 @@ export const respondWithCookie = <T>(res: Response, body: T, { isSecure, values
|
||||
};
|
||||
|
||||
const cookieOptions: Record<ImmichCookie, CookieOptions> = {
|
||||
[ImmichCookie.AUTH_TYPE]: defaults,
|
||||
[ImmichCookie.ACCESS_TOKEN]: defaults,
|
||||
[ImmichCookie.OAUTH_STATE]: defaults,
|
||||
[ImmichCookie.OAUTH_CODE_VERIFIER]: defaults,
|
||||
[ImmichCookie.AuthType]: defaults,
|
||||
[ImmichCookie.AccessToken]: defaults,
|
||||
[ImmichCookie.OAuthState]: defaults,
|
||||
[ImmichCookie.OAuthCodeVerifier]: defaults,
|
||||
// no httpOnly so that the client can know the auth state
|
||||
[ImmichCookie.IS_AUTHENTICATED]: { ...defaults, httpOnly: false },
|
||||
[ImmichCookie.SHARED_LINK_TOKEN]: { ...defaults, maxAge: Duration.fromObject({ days: 1 }).toMillis() },
|
||||
[ImmichCookie.IsAuthenticated]: { ...defaults, httpOnly: false },
|
||||
[ImmichCookie.SharedLinkToken]: { ...defaults, maxAge: Duration.fromObject({ days: 1 }).toMillis() },
|
||||
};
|
||||
|
||||
for (const { key, value } of values) {
|
||||
|
||||
Reference in New Issue
Block a user