Compare commits

...

2 Commits

Author SHA1 Message Date
Alex The Bot
e050121dbf Version v1.79.1 2023-09-22 01:37:20 +00:00
Jason Rasmussen
f0a5d39625 fix: live photo uploads (#4167)
* fix: live photo uploads

* fix: format

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
2023-09-22 08:35:25 +07:00
21 changed files with 62 additions and 42 deletions

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "machine-learning"
version = "1.79.0"
version = "1.79.1"
description = ""
authors = ["Hau Tran <alex.tran1502@gmail.com>"]
readme = "README.md"

View File

@@ -36,7 +36,7 @@ platform :android do
build_type: 'Release',
properties: {
"android.injected.version.code" => 103,
"android.injected.version.name" => "1.79.0",
"android.injected.version.name" => "1.79.1",
}
)
upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab')

View File

@@ -19,7 +19,7 @@ platform :ios do
desc "iOS Beta"
lane :beta do
increment_version_number(
version_number: "1.79.0"
version_number: "1.79.1"
)
increment_build_number(
build_number: latest_testflight_build_number + 1,

View File

@@ -3,7 +3,7 @@ Immich API
This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.79.0
- API version: 1.79.1
- Build package: org.openapitools.codegen.languages.DartClientCodegen
## Requirements

View File

@@ -2,7 +2,7 @@ name: immich_mobile
description: Immich - selfhosted backup media file on mobile phone
publish_to: "none"
version: 1.79.0+103
version: 1.79.1+103
isar_version: &isar_version 3.1.0+1
environment:

View File

@@ -5055,7 +5055,7 @@
"info": {
"title": "Immich",
"description": "Immich API",
"version": "1.79.0",
"version": "1.79.1",
"contact": {}
},
"tags": [],

View File

@@ -1,12 +1,12 @@
{
"name": "immich",
"version": "1.79.0",
"version": "1.79.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "immich",
"version": "1.79.0",
"version": "1.79.1",
"license": "UNLICENSED",
"dependencies": {
"@babel/runtime": "^7.22.11",

View File

@@ -1,6 +1,6 @@
{
"name": "immich",
"version": "1.79.0",
"version": "1.79.1",
"description": "",
"author": "",
"private": true,

View File

@@ -19,11 +19,14 @@ export interface AssetOwnerCheck extends AssetCheck {
ownerId: string;
}
export type AssetCreate = Omit<
AssetEntity,
'id' | 'createdAt' | 'updatedAt' | 'owner' | 'livePhotoVideoId' | 'library'
>;
export interface IAssetRepository {
get(id: string): Promise<AssetEntity | null>;
create(
asset: Omit<AssetEntity, 'id' | 'createdAt' | 'updatedAt' | 'ownerId' | 'libraryId' | 'livePhotoVideoId'>,
): Promise<AssetEntity>;
create(asset: AssetCreate): Promise<AssetEntity>;
remove(asset: AssetEntity): Promise<void>;
getAllByUserId(userId: string, dto: AssetSearchDto): Promise<AssetEntity[]>;
getAllByDeviceId(userId: string, deviceId: string): Promise<string[]>;
@@ -151,9 +154,7 @@ export class AssetRepository implements IAssetRepository {
});
}
create(
asset: Omit<AssetEntity, 'id' | 'createdAt' | 'updatedAt' | 'ownerId' | 'livePhotoVideoId'>,
): Promise<AssetEntity> {
create(asset: AssetCreate): Promise<AssetEntity> {
return this.assetRepository.save(asset);
}

View File

@@ -1,5 +1,5 @@
import { AuthUserDto, IJobRepository, JobName, mimeTypes, UploadFile } from '@app/domain';
import { AssetEntity, LibraryEntity, UserEntity } from '@app/infra/entities';
import { AssetEntity } from '@app/infra/entities';
import { parse } from 'node:path';
import { IAssetRepository } from './asset-repository';
import { CreateAssetDto, ImportAssetDto } from './dto/create-asset.dto';
@@ -12,14 +12,14 @@ export class AssetCore {
async create(
authUser: AuthUserDto,
dto: CreateAssetDto | ImportAssetDto,
dto: (CreateAssetDto | ImportAssetDto) & { libraryId: string },
file: UploadFile,
livePhotoAssetId?: string,
sidecarPath?: string,
): Promise<AssetEntity> {
const asset = await this.repository.create({
owner: { id: authUser.id } as UserEntity,
library: { id: dto.libraryId } as LibraryEntity,
ownerId: authUser.id,
libraryId: dto.libraryId,
checksum: file.checksum,
originalPath: file.originalPath,

View File

@@ -90,22 +90,19 @@ export class AssetService {
let livePhotoAsset: AssetEntity | null = null;
try {
const libraryId = await this.getLibraryId(authUser, dto.libraryId);
if (livePhotoFile) {
const livePhotoDto = { ...dto, assetType: AssetType.VIDEO, isVisible: false };
const livePhotoDto = { ...dto, assetType: AssetType.VIDEO, isVisible: false, libraryId };
livePhotoAsset = await this.assetCore.create(authUser, livePhotoDto, livePhotoFile);
}
if (!dto.libraryId) {
// No library given, fall back to default upload library
const defaultUploadLibrary = await this.libraryRepository.getDefaultUploadLibrary(authUser.id);
if (!defaultUploadLibrary) {
throw new InternalServerErrorException('Cannot find default upload library for user ' + authUser.id);
}
dto.libraryId = defaultUploadLibrary.id;
}
const asset = await this.assetCore.create(authUser, dto, file, livePhotoAsset?.id, sidecarFile?.originalPath);
const asset = await this.assetCore.create(
authUser,
{ ...dto, libraryId },
file,
livePhotoAsset?.id,
sidecarFile?.originalPath,
);
return { id: asset.id, duplicate: false };
} catch (error: any) {
@@ -164,7 +161,8 @@ export class AssetService {
};
try {
const asset = await this.assetCore.create(authUser, dto, assetFile, undefined, dto.sidecarPath);
const libraryId = await this.getLibraryId(authUser, dto.libraryId);
const asset = await this.assetCore.create(authUser, { ...dto, libraryId }, assetFile, undefined, dto.sidecarPath);
return { id: asset.id, duplicate: false };
} catch (error: QueryFailedError | Error | any) {
// handle duplicates with a success response
@@ -505,4 +503,25 @@ export class AssetService {
}
});
}
private async getLibraryId(authUser: AuthUserDto, libraryId?: string) {
if (libraryId) {
return libraryId;
}
let library = await this.libraryRepository.getDefaultUploadLibrary(authUser.id);
if (!library) {
library = await this.libraryRepository.create({
ownerId: authUser.id,
name: 'Default Library',
assets: [],
type: LibraryType.UPLOAD,
importPaths: [],
exclusionPatterns: [],
isVisible: true,
});
}
return library.id;
}
}

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Immich
* Immich API
*
* The version of the OpenAPI document: 1.79.0
* The version of the OpenAPI document: 1.79.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).