mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix: redirect original (#27759)
This commit is contained in:
@@ -4214,6 +4214,13 @@
|
|||||||
"name": "size",
|
"name": "size",
|
||||||
"required": false,
|
"required": false,
|
||||||
"in": "query",
|
"in": "query",
|
||||||
|
"x-immich-history": [
|
||||||
|
{
|
||||||
|
"version": "v3",
|
||||||
|
"state": "Updated",
|
||||||
|
"description": "Specifying 'original' is deprecated. Use the original endpoint directly instead"
|
||||||
|
}
|
||||||
|
],
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/AssetMediaSize"
|
"$ref": "#/components/schemas/AssetMediaSize"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,11 +166,16 @@ describe(AssetMediaController.name, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO figure out how to deal with `sendFile`
|
// TODO figure out how to deal with `sendFile`
|
||||||
describe.skip('GET /assets/:id/thumbnail', () => {
|
describe('GET /assets/:id/thumbnail', () => {
|
||||||
it('should be an authenticated route', async () => {
|
it.skip('should be an authenticated route', async () => {
|
||||||
await request(ctx.getHttpServer()).get(`/assets/${factory.uuid()}/thumbnail`);
|
await request(ctx.getHttpServer()).get(`/assets/${factory.uuid()}/thumbnail`);
|
||||||
expect(ctx.authenticate).toHaveBeenCalled();
|
expect(ctx.authenticate).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should redirect if size=original is requested', async () => {
|
||||||
|
const { status } = await request(ctx.getHttpServer()).get(`/assets/${factory.uuid()}/thumbnail?size=original`);
|
||||||
|
expect(status).toBe(302);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -126,6 +126,16 @@ export class AssetMediaController {
|
|||||||
@Res() res: Response,
|
@Res() res: Response,
|
||||||
@Next() next: NextFunction,
|
@Next() next: NextFunction,
|
||||||
) {
|
) {
|
||||||
|
if (dto.size === AssetMediaSize.Original) {
|
||||||
|
this.logger.deprecate(
|
||||||
|
'Calling the thumbnail endpoint with size=original is deprecated. Use the :id/original endpoint instead',
|
||||||
|
);
|
||||||
|
const [_, reqSearch] = req.url.split('?');
|
||||||
|
const redirSearchParams = new URLSearchParams(reqSearch);
|
||||||
|
redirSearchParams.delete('size');
|
||||||
|
return res.redirect('original' + '?' + redirSearchParams.toString());
|
||||||
|
}
|
||||||
|
|
||||||
const viewThumbnailRes = await this.service.viewThumbnail(auth, id, dto);
|
const viewThumbnailRes = await this.service.viewThumbnail(auth, id, dto);
|
||||||
|
|
||||||
if (viewThumbnailRes instanceof ImmichFileResponse) {
|
if (viewThumbnailRes instanceof ImmichFileResponse) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { createZodDto } from 'nestjs-zod';
|
import { createZodDto } from 'nestjs-zod';
|
||||||
|
import { HistoryBuilder } from 'src/decorators';
|
||||||
import { AssetMetadataUpsertItemSchema } from 'src/dtos/asset.dto';
|
import { AssetMetadataUpsertItemSchema } from 'src/dtos/asset.dto';
|
||||||
import { AssetVisibilitySchema } from 'src/enum';
|
import { AssetVisibilitySchema } from 'src/enum';
|
||||||
import { isoDatetimeToDate, JsonParsed, stringToBool } from 'src/validation';
|
import { isoDatetimeToDate, JsonParsed, stringToBool } from 'src/validation';
|
||||||
@@ -19,7 +20,11 @@ const AssetMediaSizeSchema = z.enum(AssetMediaSize).describe('Asset media size')
|
|||||||
|
|
||||||
const AssetMediaOptionsSchema = z
|
const AssetMediaOptionsSchema = z
|
||||||
.object({
|
.object({
|
||||||
size: AssetMediaSizeSchema.optional(),
|
size: AssetMediaSizeSchema.optional().meta(
|
||||||
|
new HistoryBuilder()
|
||||||
|
.updated('v3', "Specifying 'original' is deprecated. Use the original endpoint directly instead")
|
||||||
|
.getExtensions(),
|
||||||
|
),
|
||||||
edited: stringToBool.default(false).optional().describe('Return edited asset if available'),
|
edited: stringToBool.default(false).optional().describe('Return edited asset if available'),
|
||||||
})
|
})
|
||||||
.meta({ id: 'AssetMediaOptionsDto' });
|
.meta({ id: 'AssetMediaOptionsDto' });
|
||||||
|
|||||||
Reference in New Issue
Block a user