mirror of
https://github.com/immich-app/immich.git
synced 2026-02-11 19:38:54 +03:00
clean up userId and albumId
This commit is contained in:
@@ -12,11 +12,11 @@ export enum AlbumUserRole {
|
||||
@Index('IDX_427c350ad49bd3935a50baab73', ['album'])
|
||||
@Index('IDX_f48513bf9bccefd6ff3ad30bd0', ['user'])
|
||||
export class AlbumUserEntity {
|
||||
@PrimaryColumn({ type: 'uuid' })
|
||||
albumsId!: string;
|
||||
@PrimaryColumn({ type: 'uuid', name: 'albumsId' })
|
||||
albumId!: string;
|
||||
|
||||
@PrimaryColumn({ type: 'uuid' })
|
||||
usersId!: string;
|
||||
@PrimaryColumn({ type: 'uuid', name: 'usersId' })
|
||||
userId!: string;
|
||||
|
||||
@JoinColumn({ name: 'albumsId' })
|
||||
@ManyToOne(() => AlbumEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
||||
|
||||
@@ -11,19 +11,18 @@ export class AlbumUserRepository implements IAlbumUserRepository {
|
||||
constructor(@InjectRepository(AlbumUserEntity) private repository: Repository<AlbumUserEntity>) {}
|
||||
|
||||
async create(dto: Partial<AlbumUserEntity>): Promise<AlbumUserEntity> {
|
||||
const { user, album } = await this.repository.save(dto);
|
||||
return this.repository.findOneOrFail({ where: { user, album }, relations: { user: true } });
|
||||
const { userId, albumId } = await this.repository.save(dto);
|
||||
return this.repository.findOneOrFail({ where: { userId, albumId } });
|
||||
}
|
||||
|
||||
async update({ userId, albumId }: AlbumPermissionId, dto: Partial<AlbumUserEntity>): Promise<AlbumUserEntity> {
|
||||
await this.repository.update({ user: { id: userId }, album: { id: albumId } }, dto);
|
||||
await this.repository.update({ userId, albumId }, dto);
|
||||
return this.repository.findOneOrFail({
|
||||
where: { user: { id: userId }, album: { id: albumId } },
|
||||
relations: { user: true },
|
||||
where: { userId, albumId },
|
||||
});
|
||||
}
|
||||
|
||||
async delete({ userId, albumId }: AlbumPermissionId): Promise<void> {
|
||||
await this.repository.delete({ user: { id: userId }, album: { id: albumId } });
|
||||
await this.repository.delete({ userId, albumId });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,9 +231,7 @@ export class AlbumService {
|
||||
throw new BadRequestException('User not found');
|
||||
}
|
||||
|
||||
album.sharedUsers.push(
|
||||
await this.albumUserRepository.create({ user: { id: userId }, album: { id } } as AlbumUserEntity),
|
||||
);
|
||||
album.sharedUsers.push(await this.albumUserRepository.create({ userId: userId, albumId: id }));
|
||||
}
|
||||
|
||||
return mapAlbumWithoutAssets(album);
|
||||
|
||||
Reference in New Issue
Block a user