mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
chore(server): make owner as required response for AlbumResponseDto (#1579)
This commit is contained in:
parent
fb4969d5d1
commit
43fd7737f1
8 changed files with 35 additions and 16 deletions
BIN
mobile/openapi/doc/AlbumResponseDto.md
generated
BIN
mobile/openapi/doc/AlbumResponseDto.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/album_response_dto.dart
generated
BIN
mobile/openapi/lib/model/album_response_dto.dart
generated
Binary file not shown.
|
|
@ -49,6 +49,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||||
relations: {
|
relations: {
|
||||||
sharedLinks: true,
|
sharedLinks: true,
|
||||||
assets: true,
|
assets: true,
|
||||||
|
owner: true,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
ownerId,
|
ownerId,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { AlbumService } from './album.service';
|
import { AlbumService } from './album.service';
|
||||||
import { AuthUserDto } from '../../decorators/auth-user.decorator';
|
import { AuthUserDto } from '../../decorators/auth-user.decorator';
|
||||||
import { BadRequestException, NotFoundException, ForbiddenException } from '@nestjs/common';
|
import { BadRequestException, NotFoundException, ForbiddenException } from '@nestjs/common';
|
||||||
import { AlbumEntity } from '@app/infra';
|
import { AlbumEntity, UserEntity } from '@app/infra';
|
||||||
import { AlbumResponseDto, ICryptoRepository } from '@app/domain';
|
import { AlbumResponseDto, ICryptoRepository, mapUser } from '@app/domain';
|
||||||
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
|
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
|
||||||
import { IAlbumRepository } from './album-repository';
|
import { IAlbumRepository } from './album-repository';
|
||||||
import { DownloadService } from '../../modules/download/download.service';
|
import { DownloadService } from '../../modules/download/download.service';
|
||||||
|
|
@ -21,6 +21,18 @@ describe('Album service', () => {
|
||||||
email: 'auth@test.com',
|
email: 'auth@test.com',
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const albumOwner: UserEntity = Object.freeze({
|
||||||
|
...authUser,
|
||||||
|
firstName: 'auth',
|
||||||
|
lastName: 'user',
|
||||||
|
createdAt: 'date',
|
||||||
|
updatedAt: 'date',
|
||||||
|
profileImagePath: '',
|
||||||
|
shouldChangePassword: false,
|
||||||
|
oauthId: '',
|
||||||
|
tags: [],
|
||||||
|
});
|
||||||
const albumId = 'f19ab956-4761-41ea-a5d6-bae948308d58';
|
const albumId = 'f19ab956-4761-41ea-a5d6-bae948308d58';
|
||||||
const sharedAlbumOwnerId = '2222';
|
const sharedAlbumOwnerId = '2222';
|
||||||
const sharedAlbumSharedAlsoWithId = '3333';
|
const sharedAlbumSharedAlsoWithId = '3333';
|
||||||
|
|
@ -28,7 +40,8 @@ describe('Album service', () => {
|
||||||
|
|
||||||
const _getOwnedAlbum = () => {
|
const _getOwnedAlbum = () => {
|
||||||
const albumEntity = new AlbumEntity();
|
const albumEntity = new AlbumEntity();
|
||||||
albumEntity.ownerId = authUser.id;
|
albumEntity.ownerId = albumOwner.id;
|
||||||
|
albumEntity.owner = albumOwner;
|
||||||
albumEntity.id = albumId;
|
albumEntity.id = albumId;
|
||||||
albumEntity.albumName = 'name';
|
albumEntity.albumName = 'name';
|
||||||
albumEntity.createdAt = 'date';
|
albumEntity.createdAt = 'date';
|
||||||
|
|
@ -42,7 +55,8 @@ describe('Album service', () => {
|
||||||
|
|
||||||
const _getOwnedSharedAlbum = () => {
|
const _getOwnedSharedAlbum = () => {
|
||||||
const albumEntity = new AlbumEntity();
|
const albumEntity = new AlbumEntity();
|
||||||
albumEntity.ownerId = authUser.id;
|
albumEntity.ownerId = albumOwner.id;
|
||||||
|
albumEntity.owner = albumOwner;
|
||||||
albumEntity.id = albumId;
|
albumEntity.id = albumId;
|
||||||
albumEntity.albumName = 'name';
|
albumEntity.albumName = 'name';
|
||||||
albumEntity.createdAt = 'date';
|
albumEntity.createdAt = 'date';
|
||||||
|
|
@ -68,6 +82,7 @@ describe('Album service', () => {
|
||||||
const _getSharedWithAuthUserAlbum = () => {
|
const _getSharedWithAuthUserAlbum = () => {
|
||||||
const albumEntity = new AlbumEntity();
|
const albumEntity = new AlbumEntity();
|
||||||
albumEntity.ownerId = sharedAlbumOwnerId;
|
albumEntity.ownerId = sharedAlbumOwnerId;
|
||||||
|
albumEntity.owner = albumOwner;
|
||||||
albumEntity.id = albumId;
|
albumEntity.id = albumId;
|
||||||
albumEntity.albumName = 'name';
|
albumEntity.albumName = 'name';
|
||||||
albumEntity.createdAt = 'date';
|
albumEntity.createdAt = 'date';
|
||||||
|
|
@ -174,22 +189,22 @@ describe('Album service', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets an owned album', async () => {
|
it('gets an owned album', async () => {
|
||||||
const ownerId = authUser.id;
|
|
||||||
const albumId = 'f19ab956-4761-41ea-a5d6-bae948308d58';
|
const albumId = 'f19ab956-4761-41ea-a5d6-bae948308d58';
|
||||||
|
|
||||||
const albumEntity = _getOwnedAlbum();
|
const albumEntity = _getOwnedAlbum();
|
||||||
albumRepositoryMock.get.mockImplementation(() => Promise.resolve<AlbumEntity>(albumEntity));
|
albumRepositoryMock.get.mockImplementation(() => Promise.resolve<AlbumEntity>(albumEntity));
|
||||||
|
|
||||||
const expectedResult: AlbumResponseDto = {
|
const expectedResult: AlbumResponseDto = {
|
||||||
|
ownerId: albumOwner.id,
|
||||||
|
owner: mapUser(albumOwner),
|
||||||
|
id: albumId,
|
||||||
albumName: 'name',
|
albumName: 'name',
|
||||||
albumThumbnailAssetId: null,
|
|
||||||
createdAt: 'date',
|
createdAt: 'date',
|
||||||
updatedAt: 'date',
|
updatedAt: 'date',
|
||||||
id: 'f19ab956-4761-41ea-a5d6-bae948308d58',
|
|
||||||
ownerId,
|
|
||||||
shared: false,
|
|
||||||
assets: [],
|
|
||||||
sharedUsers: [],
|
sharedUsers: [],
|
||||||
|
assets: [],
|
||||||
|
albumThumbnailAssetId: null,
|
||||||
|
shared: false,
|
||||||
assetCount: 0,
|
assetCount: 0,
|
||||||
};
|
};
|
||||||
await expect(sut.getAlbumInfo(authUser, albumId)).resolves.toEqual(expectedResult);
|
await expect(sut.getAlbumInfo(authUser, albumId)).resolves.toEqual(expectedResult);
|
||||||
|
|
@ -473,6 +488,7 @@ describe('Album service', () => {
|
||||||
const albumEntity = new AlbumEntity();
|
const albumEntity = new AlbumEntity();
|
||||||
|
|
||||||
albumEntity.ownerId = authUser.id;
|
albumEntity.ownerId = authUser.id;
|
||||||
|
albumEntity.owner = albumOwner;
|
||||||
albumEntity.id = albumId;
|
albumEntity.id = albumId;
|
||||||
albumEntity.albumName = 'name';
|
albumEntity.albumName = 'name';
|
||||||
albumEntity.createdAt = 'date';
|
albumEntity.createdAt = 'date';
|
||||||
|
|
|
||||||
|
|
@ -3400,7 +3400,8 @@
|
||||||
"albumThumbnailAssetId",
|
"albumThumbnailAssetId",
|
||||||
"shared",
|
"shared",
|
||||||
"sharedUsers",
|
"sharedUsers",
|
||||||
"assets"
|
"assets",
|
||||||
|
"owner"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SharedLinkResponseDto": {
|
"SharedLinkResponseDto": {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export class AlbumResponseDto {
|
||||||
shared!: boolean;
|
shared!: boolean;
|
||||||
sharedUsers!: UserResponseDto[];
|
sharedUsers!: UserResponseDto[];
|
||||||
assets!: AssetResponseDto[];
|
assets!: AssetResponseDto[];
|
||||||
owner?: UserResponseDto;
|
owner!: UserResponseDto;
|
||||||
@ApiProperty({ type: 'integer' })
|
@ApiProperty({ type: 'integer' })
|
||||||
assetCount!: number;
|
assetCount!: number;
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ export function mapAlbum(entity: AlbumEntity): AlbumResponseDto {
|
||||||
updatedAt: entity.updatedAt,
|
updatedAt: entity.updatedAt,
|
||||||
id: entity.id,
|
id: entity.id,
|
||||||
ownerId: entity.ownerId,
|
ownerId: entity.ownerId,
|
||||||
owner: entity.owner ? mapUser(entity.owner) : undefined,
|
owner: mapUser(entity.owner),
|
||||||
sharedUsers,
|
sharedUsers,
|
||||||
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
|
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
|
||||||
assets: entity.assets?.map((assetAlbum) => mapAsset(assetAlbum.assetInfo)) || [],
|
assets: entity.assets?.map((assetAlbum) => mapAsset(assetAlbum.assetInfo)) || [],
|
||||||
|
|
@ -60,7 +60,7 @@ export function mapAlbumExcludeAssetInfo(entity: AlbumEntity): AlbumResponseDto
|
||||||
updatedAt: entity.updatedAt,
|
updatedAt: entity.updatedAt,
|
||||||
id: entity.id,
|
id: entity.id,
|
||||||
ownerId: entity.ownerId,
|
ownerId: entity.ownerId,
|
||||||
owner: entity.owner ? mapUser(entity.owner) : undefined,
|
owner: mapUser(entity.owner),
|
||||||
sharedUsers,
|
sharedUsers,
|
||||||
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
|
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
|
||||||
assets: [],
|
assets: [],
|
||||||
|
|
|
||||||
2
web/src/api/open-api/api.ts
generated
2
web/src/api/open-api/api.ts
generated
|
|
@ -281,7 +281,7 @@ export interface AlbumResponseDto {
|
||||||
* @type {UserResponseDto}
|
* @type {UserResponseDto}
|
||||||
* @memberof AlbumResponseDto
|
* @memberof AlbumResponseDto
|
||||||
*/
|
*/
|
||||||
'owner'?: UserResponseDto;
|
'owner': UserResponseDto;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
let calculateVideoDurationIntervalHandler: NodeJS.Timer;
|
let calculateVideoDurationIntervalHandler: NodeJS.Timer;
|
||||||
let videoProgress = '00:00';
|
let videoProgress = '00:00';
|
||||||
let videoUrl: string;
|
let videoUrl: string;
|
||||||
|
$: isPublicShared = publicSharedKey !== '';
|
||||||
|
|
||||||
const loadVideoData = async (isLivePhoto: boolean) => {
|
const loadVideoData = async (isLivePhoto: boolean) => {
|
||||||
isThumbnailVideoPlaying = false;
|
isThumbnailVideoPlaying = false;
|
||||||
|
|
@ -183,7 +184,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if asset.isFavorite}
|
{#if asset.isFavorite && !isPublicShared}
|
||||||
<div class="w-full absolute bottom-2 left-2 z-10">
|
<div class="w-full absolute bottom-2 left-2 z-10">
|
||||||
<Star size="24" color={'white'} />
|
<Star size="24" color={'white'} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue