diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 16c0a8023b..0f27662b81 100644 Binary files a/mobile/openapi/README.md and b/mobile/openapi/README.md differ diff --git a/mobile/openapi/doc/AssetApi.md b/mobile/openapi/doc/AssetApi.md index 0284488148..6862a236ff 100644 Binary files a/mobile/openapi/doc/AssetApi.md and b/mobile/openapi/doc/AssetApi.md differ diff --git a/mobile/openapi/lib/api/asset_api.dart b/mobile/openapi/lib/api/asset_api.dart index 84b73ea9aa..2d7f17c161 100644 Binary files a/mobile/openapi/lib/api/asset_api.dart and b/mobile/openapi/lib/api/asset_api.dart differ diff --git a/mobile/openapi/test/asset_api_test.dart b/mobile/openapi/test/asset_api_test.dart index b87cacf29a..27bb254528 100644 Binary files a/mobile/openapi/test/asset_api_test.dart and b/mobile/openapi/test/asset_api_test.dart differ diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 0c3a480a27..a3abe1ef9b 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -2318,52 +2318,6 @@ ] } }, - "/asset/{deviceId}": { - "get": { - "deprecated": true, - "operationId": "getUserAssetsByDeviceId", - "parameters": [ - { - "name": "deviceId", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "items": { - "type": "string" - }, - "type": "array" - } - } - }, - "description": "" - } - }, - "security": [ - { - "bearer": [] - }, - { - "cookie": [] - }, - { - "api_key": [] - } - ], - "summary": "Use /asset/device/:deviceId instead - Remove in 1.92 release", - "tags": [ - "Asset" - ] - } - }, "/asset/{id}": { "put": { "operationId": "updateAsset", diff --git a/open-api/typescript-sdk/client/api.ts b/open-api/typescript-sdk/client/api.ts index f1cbdae068..2124ea6e63 100644 --- a/open-api/typescript-sdk/client/api.ts +++ b/open-api/typescript-sdk/client/api.ts @@ -7792,50 +7792,6 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Use /asset/device/:deviceId instead - Remove in 1.92 release - * @param {string} deviceId - * @param {*} [options] Override http request option. - * @deprecated - * @throws {RequiredError} - */ - getUserAssetsByDeviceId: async (deviceId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'deviceId' is not null or undefined - assertParamExists('getUserAssetsByDeviceId', 'deviceId', deviceId) - const localVarPath = `/asset/{deviceId}` - .replace(`{${"deviceId"}}`, encodeURIComponent(String(deviceId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication cookie required - - // authentication api_key required - await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration) - - // authentication bearer required - // http bearer authentication required - await setBearerAuthToObject(localVarHeaderParameter, configuration) - - - setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -8794,18 +8750,6 @@ export const AssetApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.getTimeBuckets(size, albumId, isArchived, isFavorite, isTrashed, key, personId, userId, withPartners, withStacked, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, - /** - * - * @summary Use /asset/device/:deviceId instead - Remove in 1.92 release - * @param {string} deviceId - * @param {*} [options] Override http request option. - * @deprecated - * @throws {RequiredError} - */ - async getUserAssetsByDeviceId(deviceId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getUserAssetsByDeviceId(deviceId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, /** * * @param {BulkIdsDto} bulkIdsDto @@ -9139,17 +9083,6 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath getTimeBuckets(requestParameters: AssetApiGetTimeBucketsRequest, options?: AxiosRequestConfig): AxiosPromise> { return localVarFp.getTimeBuckets(requestParameters.size, requestParameters.albumId, requestParameters.isArchived, requestParameters.isFavorite, requestParameters.isTrashed, requestParameters.key, requestParameters.personId, requestParameters.userId, requestParameters.withPartners, requestParameters.withStacked, options).then((request) => request(axios, basePath)); }, - /** - * - * @summary Use /asset/device/:deviceId instead - Remove in 1.92 release - * @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @deprecated - * @throws {RequiredError} - */ - getUserAssetsByDeviceId(requestParameters: AssetApiGetUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig): AxiosPromise> { - return localVarFp.getUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(axios, basePath)); - }, /** * * @param {AssetApiRestoreAssetsRequest} requestParameters Request parameters. @@ -9723,20 +9656,6 @@ export interface AssetApiGetTimeBucketsRequest { readonly withStacked?: boolean } -/** - * Request parameters for getUserAssetsByDeviceId operation in AssetApi. - * @export - * @interface AssetApiGetUserAssetsByDeviceIdRequest - */ -export interface AssetApiGetUserAssetsByDeviceIdRequest { - /** - * - * @type {string} - * @memberof AssetApiGetUserAssetsByDeviceId - */ - readonly deviceId: string -} - /** * Request parameters for restoreAssets operation in AssetApi. * @export @@ -10478,19 +10397,6 @@ export class AssetApi extends BaseAPI { return AssetApiFp(this.configuration).getTimeBuckets(requestParameters.size, requestParameters.albumId, requestParameters.isArchived, requestParameters.isFavorite, requestParameters.isTrashed, requestParameters.key, requestParameters.personId, requestParameters.userId, requestParameters.withPartners, requestParameters.withStacked, options).then((request) => request(this.axios, this.basePath)); } - /** - * - * @summary Use /asset/device/:deviceId instead - Remove in 1.92 release - * @param {AssetApiGetUserAssetsByDeviceIdRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @deprecated - * @throws {RequiredError} - * @memberof AssetApi - */ - public getUserAssetsByDeviceId(requestParameters: AssetApiGetUserAssetsByDeviceIdRequest, options?: AxiosRequestConfig) { - return AssetApiFp(this.configuration).getUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(this.axios, this.basePath)); - } - /** * * @param {AssetApiRestoreAssetsRequest} requestParameters Request parameters. diff --git a/server/src/domain/asset/dto/asset.dto.ts b/server/src/domain/asset/dto/asset.dto.ts index ac50f22426..ec3f5df478 100644 --- a/server/src/domain/asset/dto/asset.dto.ts +++ b/server/src/domain/asset/dto/asset.dto.ts @@ -17,6 +17,12 @@ import { import { Optional, QueryBoolean, QueryDate, ValidateUUID } from '../../domain.util'; import { BulkIdsDto } from '../response-dto'; +export class DeviceIdDto { + @IsNotEmpty() + @IsString() + deviceId!: string; +} + export enum AssetOrder { ASC = 'asc', DESC = 'desc', diff --git a/server/src/immich/api-v1/asset/asset-repository.ts b/server/src/immich/api-v1/asset/asset-repository.ts index 5adf663cb4..5ceb066013 100644 --- a/server/src/immich/api-v1/asset/asset-repository.ts +++ b/server/src/immich/api-v1/asset/asset-repository.ts @@ -25,7 +25,6 @@ export interface IAssetRepository { create(asset: AssetCreate): Promise; upsertExif(exif: Partial): Promise; getAllByUserId(userId: string, dto: AssetSearchDto): Promise; - getAllByDeviceId(userId: string, deviceId: string): Promise; getById(assetId: string): Promise; getLocationsByUserId(userId: string): Promise; getDetectedObjectsByUserId(userId: string): Promise; @@ -170,27 +169,6 @@ export class AssetRepository implements IAssetRepository { await this.exifRepository.upsert(exif, { conflictPaths: ['assetId'] }); } - /** - * Get assets by device's Id on the database - * @param ownerId - * @param deviceId - * - * @returns Promise - Array of assetIds belong to the device - */ - async getAllByDeviceId(ownerId: string, deviceId: string): Promise { - const items = await this.assetRepository.find({ - select: { deviceAssetId: true }, - where: { - ownerId, - deviceId, - isVisible: true, - }, - withDeleted: true, - }); - - return items.map((asset) => asset.deviceAssetId); - } - /** * Get assets by checksums on the database * @param ownerId diff --git a/server/src/immich/api-v1/asset/asset.controller.ts b/server/src/immich/api-v1/asset/asset.controller.ts index 17d850cea9..0487d6f56d 100644 --- a/server/src/immich/api-v1/asset/asset.controller.ts +++ b/server/src/immich/api-v1/asset/asset.controller.ts @@ -15,7 +15,7 @@ import { UseInterceptors, ValidationPipe, } from '@nestjs/common'; -import { ApiBody, ApiConsumes, ApiHeader, ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiBody, ApiConsumes, ApiHeader, ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../../app.guard'; import { sendFile } from '../../app.utils'; @@ -27,7 +27,6 @@ import { AssetBulkUploadCheckDto } from './dto/asset-check.dto'; import { AssetSearchDto } from './dto/asset-search.dto'; import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; import { CreateAssetDto } from './dto/create-asset.dto'; -import { DeviceIdDto } from './dto/device-id.dto'; import { GetAssetThumbnailDto } from './dto/get-asset-thumbnail.dto'; import { ServeFileDto } from './dto/serve-file.dto'; import { AssetBulkUploadCheckResponseDto } from './response-dto/asset-check-response.dto'; @@ -141,15 +140,6 @@ export class AssetController { return this.assetService.getAllAssets(auth, dto); } - /** - * @deprecated Use /asset/device/:deviceId instead - Remove at 1.92 release - */ - @Get('/:deviceId') - @ApiOperation({ deprecated: true, summary: 'Use /asset/device/:deviceId instead - Remove in 1.92 release' }) - getUserAssetsByDeviceId(@Auth() auth: AuthDto, @Param() { deviceId }: DeviceIdDto) { - return this.assetService.getUserAssetsByDeviceId(auth, deviceId); - } - /** * Get a single asset's information */ diff --git a/server/src/immich/api-v1/asset/asset.service.spec.ts b/server/src/immich/api-v1/asset/asset.service.spec.ts index 6fa91eb2c9..c91d3efab6 100644 --- a/server/src/immich/api-v1/asset/asset.service.spec.ts +++ b/server/src/immich/api-v1/asset/asset.service.spec.ts @@ -56,32 +56,6 @@ const _getAsset_1 = () => { return asset_1; }; -const _getAsset_2 = () => { - const asset_2 = new AssetEntity(); - - asset_2.id = 'id_2'; - asset_2.ownerId = 'user_id_1'; - asset_2.deviceAssetId = 'device_asset_id_2'; - asset_2.deviceId = 'device_id_1'; - asset_2.type = AssetType.VIDEO; - asset_2.originalPath = 'fake_path/asset_2.jpeg'; - asset_2.resizePath = ''; - asset_2.fileModifiedAt = new Date('2022-06-19T23:41:36.910Z'); - asset_2.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z'); - asset_2.updatedAt = new Date('2022-06-19T23:41:36.910Z'); - asset_2.isFavorite = false; - asset_2.isArchived = false; - asset_2.webpPath = ''; - asset_2.encodedVideoPath = ''; - asset_2.duration = '0:00:00.000000'; - - return asset_2; -}; - -const _getAssets = () => { - return [_getAsset_1(), _getAsset_2()]; -}; - describe('AssetService', () => { let sut: AssetService; let accessMock: IAccessRepositoryMock; @@ -97,7 +71,6 @@ describe('AssetService', () => { upsertExif: jest.fn(), getAllByUserId: jest.fn(), - getAllByDeviceId: jest.fn(), getById: jest.fn(), getDetectedObjectsByUserId: jest.fn(), getLocationsByUserId: jest.fn(), @@ -199,20 +172,6 @@ describe('AssetService', () => { }); }); - it('get assets by device id', async () => { - const assets = _getAssets(); - - assetRepositoryMock.getAllByDeviceId.mockImplementation(() => - Promise.resolve(Array.from(assets.map((asset) => asset.deviceAssetId))), - ); - - const deviceId = 'device_id_1'; - const result = await sut.getUserAssetsByDeviceId(authStub.user1, deviceId); - - expect(result.length).toEqual(2); - expect(result).toEqual(assets.map((asset) => asset.deviceAssetId)); - }); - describe('bulkUploadCheck', () => { it('should accept hex and base64 checksums', async () => { const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex'); diff --git a/server/src/immich/api-v1/asset/asset.service.ts b/server/src/immich/api-v1/asset/asset.service.ts index 6cfdfff541..e611060ca5 100644 --- a/server/src/immich/api-v1/asset/asset.service.ts +++ b/server/src/immich/api-v1/asset/asset.service.ts @@ -111,10 +111,6 @@ export class AssetService { } } - public async getUserAssetsByDeviceId(auth: AuthDto, deviceId: string) { - return this._assetRepository.getAllByDeviceId(auth.user.id, deviceId); - } - public async getAllAssets(auth: AuthDto, dto: AssetSearchDto): Promise { const userId = dto.userId || auth.user.id; await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId); diff --git a/server/src/immich/api-v1/asset/dto/device-id.dto.ts b/server/src/immich/api-v1/asset/dto/device-id.dto.ts deleted file mode 100644 index cae5f60c8b..0000000000 --- a/server/src/immich/api-v1/asset/dto/device-id.dto.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { IsNotEmpty, IsString } from 'class-validator'; - -export class DeviceIdDto { - @IsNotEmpty() - @IsString() - deviceId!: string; -} diff --git a/server/src/immich/controllers/asset.controller.ts b/server/src/immich/controllers/asset.controller.ts index c6919f315c..fe4117be2a 100644 --- a/server/src/immich/controllers/asset.controller.ts +++ b/server/src/immich/controllers/asset.controller.ts @@ -10,6 +10,7 @@ import { AssetStatsResponseDto, AuthDto, BulkIdsDto, + DeviceIdDto, DownloadInfoDto, DownloadResponseDto, MapMarkerDto, @@ -41,7 +42,6 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; -import { DeviceIdDto } from '../api-v1/asset/dto/device-id.dto'; import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../app.guard'; import { UseValidation, asStreamableFile, sendFile } from '../app.utils'; import { Route } from '../interceptors';