mirror of
https://github.com/immich-app/immich.git
synced 2026-02-12 11:58:15 +03:00
fix e2e tests and some bugs
This commit is contained in:
@@ -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