1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

chore(server): remove old device id endpoint (#6578)

* chore: remove old endpoint

* chore: open api

* chore: remove old tests
This commit is contained in:
Jason Rasmussen 2024-01-22 21:54:53 -05:00 committed by GitHub
parent 234a95960b
commit a00768c9e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 8 additions and 226 deletions

BIN
mobile/openapi/README.md generated

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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}": { "/asset/{id}": {
"put": { "put": {
"operationId": "updateAsset", "operationId": "updateAsset",

View File

@ -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<RequestArgs> => {
// 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); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.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); const localVarAxiosArgs = await localVarAxiosParamCreator.getTimeBuckets(size, albumId, isArchived, isFavorite, isTrashed, key, personId, userId, withPartners, withStacked, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); 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<Array<string>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getUserAssetsByDeviceId(deviceId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/** /**
* *
* @param {BulkIdsDto} bulkIdsDto * @param {BulkIdsDto} bulkIdsDto
@ -9139,17 +9083,6 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
getTimeBuckets(requestParameters: AssetApiGetTimeBucketsRequest, options?: AxiosRequestConfig): AxiosPromise<Array<TimeBucketResponseDto>> { getTimeBuckets(requestParameters: AssetApiGetTimeBucketsRequest, options?: AxiosRequestConfig): AxiosPromise<Array<TimeBucketResponseDto>> {
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)); 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<Array<string>> {
return localVarFp.getUserAssetsByDeviceId(requestParameters.deviceId, options).then((request) => request(axios, basePath));
},
/** /**
* *
* @param {AssetApiRestoreAssetsRequest} requestParameters Request parameters. * @param {AssetApiRestoreAssetsRequest} requestParameters Request parameters.
@ -9723,20 +9656,6 @@ export interface AssetApiGetTimeBucketsRequest {
readonly withStacked?: boolean 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. * Request parameters for restoreAssets operation in AssetApi.
* @export * @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)); 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. * @param {AssetApiRestoreAssetsRequest} requestParameters Request parameters.

View File

@ -17,6 +17,12 @@ import {
import { Optional, QueryBoolean, QueryDate, ValidateUUID } from '../../domain.util'; import { Optional, QueryBoolean, QueryDate, ValidateUUID } from '../../domain.util';
import { BulkIdsDto } from '../response-dto'; import { BulkIdsDto } from '../response-dto';
export class DeviceIdDto {
@IsNotEmpty()
@IsString()
deviceId!: string;
}
export enum AssetOrder { export enum AssetOrder {
ASC = 'asc', ASC = 'asc',
DESC = 'desc', DESC = 'desc',

View File

@ -25,7 +25,6 @@ export interface IAssetRepository {
create(asset: AssetCreate): Promise<AssetEntity>; create(asset: AssetCreate): Promise<AssetEntity>;
upsertExif(exif: Partial<ExifEntity>): Promise<void>; upsertExif(exif: Partial<ExifEntity>): Promise<void>;
getAllByUserId(userId: string, dto: AssetSearchDto): Promise<AssetEntity[]>; getAllByUserId(userId: string, dto: AssetSearchDto): Promise<AssetEntity[]>;
getAllByDeviceId(userId: string, deviceId: string): Promise<string[]>;
getById(assetId: string): Promise<AssetEntity>; getById(assetId: string): Promise<AssetEntity>;
getLocationsByUserId(userId: string): Promise<CuratedLocationsResponseDto[]>; getLocationsByUserId(userId: string): Promise<CuratedLocationsResponseDto[]>;
getDetectedObjectsByUserId(userId: string): Promise<CuratedObjectsResponseDto[]>; getDetectedObjectsByUserId(userId: string): Promise<CuratedObjectsResponseDto[]>;
@ -170,27 +169,6 @@ export class AssetRepository implements IAssetRepository {
await this.exifRepository.upsert(exif, { conflictPaths: ['assetId'] }); await this.exifRepository.upsert(exif, { conflictPaths: ['assetId'] });
} }
/**
* Get assets by device's Id on the database
* @param ownerId
* @param deviceId
*
* @returns Promise<string[]> - Array of assetIds belong to the device
*/
async getAllByDeviceId(ownerId: string, deviceId: string): Promise<string[]> {
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 * Get assets by checksums on the database
* @param ownerId * @param ownerId

View File

@ -15,7 +15,7 @@ import {
UseInterceptors, UseInterceptors,
ValidationPipe, ValidationPipe,
} from '@nestjs/common'; } 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 { NextFunction, Response } from 'express';
import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../../app.guard'; import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../../app.guard';
import { sendFile } from '../../app.utils'; import { sendFile } from '../../app.utils';
@ -27,7 +27,6 @@ import { AssetBulkUploadCheckDto } from './dto/asset-check.dto';
import { AssetSearchDto } from './dto/asset-search.dto'; import { AssetSearchDto } from './dto/asset-search.dto';
import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto';
import { CreateAssetDto } from './dto/create-asset.dto'; import { CreateAssetDto } from './dto/create-asset.dto';
import { DeviceIdDto } from './dto/device-id.dto';
import { GetAssetThumbnailDto } from './dto/get-asset-thumbnail.dto'; import { GetAssetThumbnailDto } from './dto/get-asset-thumbnail.dto';
import { ServeFileDto } from './dto/serve-file.dto'; import { ServeFileDto } from './dto/serve-file.dto';
import { AssetBulkUploadCheckResponseDto } from './response-dto/asset-check-response.dto'; import { AssetBulkUploadCheckResponseDto } from './response-dto/asset-check-response.dto';
@ -141,15 +140,6 @@ export class AssetController {
return this.assetService.getAllAssets(auth, dto); 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 * Get a single asset's information
*/ */

View File

@ -56,32 +56,6 @@ const _getAsset_1 = () => {
return asset_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', () => { describe('AssetService', () => {
let sut: AssetService; let sut: AssetService;
let accessMock: IAccessRepositoryMock; let accessMock: IAccessRepositoryMock;
@ -97,7 +71,6 @@ describe('AssetService', () => {
upsertExif: jest.fn(), upsertExif: jest.fn(),
getAllByUserId: jest.fn(), getAllByUserId: jest.fn(),
getAllByDeviceId: jest.fn(),
getById: jest.fn(), getById: jest.fn(),
getDetectedObjectsByUserId: jest.fn(), getDetectedObjectsByUserId: jest.fn(),
getLocationsByUserId: 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<string[]>(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', () => { describe('bulkUploadCheck', () => {
it('should accept hex and base64 checksums', async () => { it('should accept hex and base64 checksums', async () => {
const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex'); const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex');

View File

@ -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<AssetResponseDto[]> { public async getAllAssets(auth: AuthDto, dto: AssetSearchDto): Promise<AssetResponseDto[]> {
const userId = dto.userId || auth.user.id; const userId = dto.userId || auth.user.id;
await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId); await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId);

View File

@ -1,7 +0,0 @@
import { IsNotEmpty, IsString } from 'class-validator';
export class DeviceIdDto {
@IsNotEmpty()
@IsString()
deviceId!: string;
}

View File

@ -10,6 +10,7 @@ import {
AssetStatsResponseDto, AssetStatsResponseDto,
AuthDto, AuthDto,
BulkIdsDto, BulkIdsDto,
DeviceIdDto,
DownloadInfoDto, DownloadInfoDto,
DownloadResponseDto, DownloadResponseDto,
MapMarkerDto, MapMarkerDto,
@ -41,7 +42,6 @@ import {
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { NextFunction, Response } from 'express'; import { NextFunction, Response } from 'express';
import { DeviceIdDto } from '../api-v1/asset/dto/device-id.dto';
import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../app.guard'; import { Auth, Authenticated, FileResponse, SharedLinkRoute } from '../app.guard';
import { UseValidation, asStreamableFile, sendFile } from '../app.utils'; import { UseValidation, asStreamableFile, sendFile } from '../app.utils';
import { Route } from '../interceptors'; import { Route } from '../interceptors';