chore: remove all deprecated endpoints/properties from server and mobile app (#9724)

* chore: remove deprecated title property from MemoryLaneResponseDto

* chore: remove deprecated webpPath and resizePath from MetadataSearchDto

* chore: remove deprecated sharedUserIds property from Album AddUsersDto

* chore: remove deprecated sharedUsers property from AlbumResponseDto

* chore: remove deprecated sharedWithUserIds property from CreateAlbumDto

* chore: remove deprecated isExternal and isReadOnly properties from AssetResponseDto

* chore: remove deprecated /server-info endpoint

* chore: bloody linters
This commit is contained in:
Zack Pollard 2024-05-24 15:37:01 +01:00 committed by GitHub
parent 1f5d82e9d9
commit 39d2c4f37b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 66 additions and 451 deletions

View file

@ -1,6 +1,5 @@
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { EndpointLifecycle } from 'src/decorators';
import {
ServerConfigDto,
ServerFeaturesDto,
@ -23,13 +22,6 @@ export class ServerInfoController {
private versionService: VersionService,
) {}
@Get()
@EndpointLifecycle({ deprecatedAt: 'v1.106.0' })
@Authenticated()
getServerInfo(): Promise<ServerStorageResponseDto> {
return this.service.getStorage();
}
@Get('storage')
@Authenticated()
getStorage(): Promise<ServerStorageResponseDto> {

View file

@ -2,7 +2,6 @@ import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { ArrayNotEmpty, IsArray, IsEnum, IsString, ValidateNested } from 'class-validator';
import _ from 'lodash';
import { PropertyLifecycle } from 'src/decorators';
import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { UserResponseDto, mapUser } from 'src/dtos/user.dto';
@ -25,10 +24,6 @@ export class AlbumUserAddDto {
}
export class AddUsersDto {
@ValidateUUID({ each: true, optional: true })
@PropertyLifecycle({ deprecatedAt: 'v1.102.0' })
sharedUserIds?: string[];
@ArrayNotEmpty()
albumUsers!: AlbumUserAddDto[];
}
@ -55,13 +50,8 @@ export class CreateAlbumDto {
@IsArray()
@ValidateNested({ each: true })
@Type(() => AlbumUserCreateDto)
@PropertyLifecycle({ addedAt: 'v1.104.0' })
albumUsers?: AlbumUserCreateDto[];
@ValidateUUID({ optional: true, each: true })
@PropertyLifecycle({ deprecatedAt: 'v1.104.0' })
sharedWithUserIds?: string[];
@ValidateUUID({ optional: true, each: true })
assetIds?: string[];
}
@ -137,8 +127,6 @@ export class AlbumResponseDto {
updatedAt!: Date;
albumThumbnailAssetId!: string | null;
shared!: boolean;
@PropertyLifecycle({ deprecatedAt: 'v1.102.0' })
sharedUsers!: UserResponseDto[];
albumUsers!: AlbumUserResponseDto[];
hasSharedLink!: boolean;
assets!: AssetResponseDto[];
@ -192,7 +180,6 @@ export const mapAlbum = (entity: AlbumEntity, withAssets: boolean, auth?: AuthDt
id: entity.id,
ownerId: entity.ownerId,
owner: mapUser(entity.owner),
sharedUsers,
albumUsers: albumUsersSorted,
shared: hasSharedUser || hasSharedLink,
hasSharedLink,

View file

@ -37,10 +37,6 @@ export class AssetResponseDto extends SanitizedAssetResponseDto {
isArchived!: boolean;
isTrashed!: boolean;
isOffline!: boolean;
@PropertyLifecycle({ deprecatedAt: 'v1.104.0' })
isExternal?: boolean;
@PropertyLifecycle({ deprecatedAt: 'v1.104.0' })
isReadOnly?: boolean;
exifInfo?: ExifResponseDto;
smartInfo?: SmartInfoResponseDto;
tags?: TagResponseDto[];
@ -129,17 +125,12 @@ export function mapAsset(entity: AssetEntity, options: AssetMapOptions = {}): As
: undefined,
stackCount: entity.stack?.assets?.length ?? null,
isOffline: entity.isOffline,
isExternal: false,
isReadOnly: false,
hasMetadata: true,
duplicateId: entity.duplicateId,
};
}
export class MemoryLaneResponseDto {
@PropertyLifecycle({ deprecatedAt: 'v1.100.0' })
title!: string;
@ApiProperty({ type: 'integer' })
yearsAgo!: number;

View file

@ -1,7 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, IsInt, IsNotEmpty, IsString, Max, Min } from 'class-validator';
import { PropertyLifecycle } from 'src/decorators';
import { AlbumResponseDto } from 'src/dtos/album.dto';
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
import { AssetOrder } from 'src/entities/album.entity';
@ -155,18 +154,6 @@ export class MetadataSearchDto extends BaseSearchDto {
@Optional()
originalPath?: string;
@IsString()
@IsNotEmpty()
@Optional()
@PropertyLifecycle({ deprecatedAt: 'v1.100.0' })
resizePath?: string;
@IsString()
@IsNotEmpty()
@Optional()
@PropertyLifecycle({ deprecatedAt: 'v1.100.0' })
webpPath?: string;
@IsString()
@IsNotEmpty()
@Optional()

View file

@ -185,7 +185,7 @@ describe(AlbumService.name, () => {
await sut.create(authStub.admin, {
albumName: 'Empty album',
sharedWithUserIds: ['user-id'],
albumUsers: [{ userId: 'user-id', role: AlbumUserRole.EDITOR }],
description: '',
assetIds: ['123'],
});
@ -208,7 +208,7 @@ describe(AlbumService.name, () => {
await expect(
sut.create(authStub.admin, {
albumName: 'Empty album',
sharedWithUserIds: ['user-3'],
albumUsers: [{ userId: 'user-3', role: AlbumUserRole.EDITOR }],
}),
).rejects.toBeInstanceOf(BadRequestException);
expect(userMock.get).toHaveBeenCalledWith('user-3', {});

View file

@ -14,7 +14,7 @@ import {
} from 'src/dtos/album.dto';
import { BulkIdResponseDto, BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { AlbumUserEntity, AlbumUserRole } from 'src/entities/album-user.entity';
import { AlbumUserEntity } from 'src/entities/album-user.entity';
import { AlbumEntity } from 'src/entities/album.entity';
import { AssetEntity } from 'src/entities/asset.entity';
import { IAccessRepository } from 'src/interfaces/access.interface';
@ -115,9 +115,6 @@ export class AlbumService {
async create(auth: AuthDto, dto: CreateAlbumDto): Promise<AlbumResponseDto> {
const albumUsers = dto.albumUsers || [];
for (const userId of dto.sharedWithUserIds || []) {
albumUsers.push({ userId, role: AlbumUserRole.EDITOR });
}
for (const { userId } of albumUsers) {
const exists = await this.userRepository.get(userId, {});
@ -216,15 +213,7 @@ export class AlbumService {
return results;
}
async addUsers(auth: AuthDto, id: string, { albumUsers, sharedUserIds }: AddUsersDto): Promise<AlbumResponseDto> {
// Remove once deprecated sharedUserIds is removed
if (!albumUsers) {
if (!sharedUserIds) {
throw new BadRequestException('No users provided');
}
albumUsers = sharedUserIds.map((userId) => ({ userId, role: AlbumUserRole.EDITOR }));
}
async addUsers(auth: AuthDto, id: string, { albumUsers }: AddUsersDto): Promise<AlbumResponseDto> {
await this.access.requirePermission(auth, Permission.ALBUM_SHARE, id);
const album = await this.findOrFail(id, { withAssets: false });

View file

@ -78,9 +78,6 @@ export class SearchService {
checksum = Buffer.from(dto.checksum, encoding);
}
dto.previewPath ??= dto.resizePath;
dto.thumbnailPath ??= dto.webpPath;
const page = dto.page ?? 1;
const size = dto.size || 250;
const enumToOrder = { [AssetOrder.ASC]: 'ASC', [AssetOrder.DESC]: 'DESC' } as const;