mirror of
https://github.com/immich-app/immich.git
synced 2026-02-11 03:17:59 +03:00
fix e2e tests and some bugs
This commit is contained in:
@@ -79,11 +79,28 @@ describe('/album', () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
await utils.updateAlbumUser(user2.accessToken, {
|
||||
id: albums[3].id,
|
||||
userId: user1.userId,
|
||||
updateAlbumUserDto: { role: AlbumUserRole.Editor },
|
||||
});
|
||||
// Make editor
|
||||
await Promise.all([
|
||||
utils.updateAlbumUser(user1.accessToken, {
|
||||
id: albums[0].id,
|
||||
userId: user2.userId,
|
||||
updateAlbumUserDto: { role: AlbumUserRole.Editor },
|
||||
}),
|
||||
utils.updateAlbumUser(user2.accessToken, {
|
||||
id: albums[3].id,
|
||||
userId: user1.userId,
|
||||
updateAlbumUserDto: { role: AlbumUserRole.Editor },
|
||||
}),
|
||||
utils.updateAlbumUser(user3.accessToken, {
|
||||
id: albums[6].id,
|
||||
userId: user1.userId,
|
||||
updateAlbumUserDto: { role: AlbumUserRole.Editor },
|
||||
}),
|
||||
]);
|
||||
|
||||
albums[0].albumUsers[0].role = AlbumUserRole.Editor;
|
||||
albums[3].albumUsers[0].role = AlbumUserRole.Editor;
|
||||
albums[6].albumUsers[0].role = AlbumUserRole.Editor;
|
||||
|
||||
await addAssetsToAlbum(
|
||||
{ id: albums[3].id, bulkIdsDto: { ids: [user1Asset1.id] } },
|
||||
@@ -364,6 +381,7 @@ describe('/album', () => {
|
||||
albumThumbnailAssetId: null,
|
||||
shared: false,
|
||||
sharedUsers: [],
|
||||
albumUsers: [],
|
||||
hasSharedLink: false,
|
||||
assets: [],
|
||||
assetCount: 0,
|
||||
|
||||
@@ -53,7 +53,7 @@ export class AlbumEntity {
|
||||
@Column({ comment: 'Asset ID to be used as thumbnail', nullable: true })
|
||||
albumThumbnailAssetId!: string | null;
|
||||
|
||||
@OneToMany(() => AlbumUserEntity, ({ album }) => album)
|
||||
@OneToMany(() => AlbumUserEntity, ({ album }) => album, { cascade: true, onDelete: 'CASCADE' })
|
||||
albumUsers!: AlbumUserEntity[];
|
||||
|
||||
@ManyToMany(() => AssetEntity, (asset) => asset.albums)
|
||||
|
||||
@@ -214,7 +214,7 @@ export class AlbumService {
|
||||
async addUsers(auth: AuthDto, id: string, dto: AddUsersDto): Promise<AlbumResponseDto> {
|
||||
await this.access.requirePermission(auth, Permission.ALBUM_SHARE, id);
|
||||
|
||||
const album = await this.findOrFail(id, { withAssets: true });
|
||||
const album = await this.findOrFail(id, { withAssets: false });
|
||||
|
||||
for (const userId of dto.sharedUserIds) {
|
||||
if (album.ownerId === userId) {
|
||||
@@ -234,7 +234,7 @@ export class AlbumService {
|
||||
album.albumUsers.push(await this.albumUserRepository.create({ userId: userId, albumId: id }));
|
||||
}
|
||||
|
||||
return mapAlbumWithoutAssets(album);
|
||||
return this.findOrFail(id, { withAssets: true }).then(mapAlbumWithoutAssets);
|
||||
}
|
||||
|
||||
async removeUser(auth: AuthDto, id: string, userId: string | 'me'): Promise<void> {
|
||||
@@ -264,13 +264,6 @@ export class AlbumService {
|
||||
async updateUser(auth: AuthDto, id: string, userId: string, dto: Partial<AlbumUserEntity>): Promise<void> {
|
||||
await this.access.requirePermission(auth, Permission.ALBUM_SHARE, id);
|
||||
|
||||
const album = await this.findOrFail(id, { withAssets: false });
|
||||
|
||||
const permission = album.albumUsers.find(({ user: { id } }) => id === userId);
|
||||
if (!permission) {
|
||||
throw new BadRequestException('Album not shared with user');
|
||||
}
|
||||
|
||||
await this.albumUserRepository.update({ albumId: id, userId }, { role: dto.role });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user