You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-10 23:22:22 +02:00
fix(server): cannot share album to owner (#18802)
* fix(server): create shared album * add test * trigger ci * resolve conversation
This commit is contained in:
@@ -210,6 +210,17 @@ describe(AlbumService.name, () => {
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if the userId is the ownerId', async () => {
|
||||
mocks.user.get.mockResolvedValue(userStub.admin);
|
||||
await expect(
|
||||
sut.create(authStub.admin, {
|
||||
albumName: 'Empty album',
|
||||
albumUsers: [{ userId: userStub.admin.id, role: AlbumUserRole.EDITOR }],
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
expect(mocks.album.create).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', () => {
|
||||
|
@@ -93,6 +93,10 @@ export class AlbumService extends BaseService {
|
||||
if (!exists) {
|
||||
throw new BadRequestException('User not found');
|
||||
}
|
||||
|
||||
if (userId == auth.user.id) {
|
||||
throw new BadRequestException('Cannot share album with owner');
|
||||
}
|
||||
}
|
||||
|
||||
const allowedAssetIdsSet = await this.checkAccess({
|
||||
|
Reference in New Issue
Block a user