refactor(server): user core (#4733)

This commit is contained in:
Jason Rasmussen
2023-10-31 11:01:32 -04:00
committed by GitHub
parent 2377df9dae
commit 088d5addf2
9 changed files with 160 additions and 304 deletions
@@ -174,7 +174,7 @@ describe(AlbumService.name, () => {
albumThumbnailAssetId: '123',
});
expect(userMock.get).toHaveBeenCalledWith('user-id');
expect(userMock.get).toHaveBeenCalledWith('user-id', {});
});
it('should require valid userIds', async () => {
@@ -185,7 +185,7 @@ describe(AlbumService.name, () => {
sharedWithUserIds: ['user-3'],
}),
).rejects.toBeInstanceOf(BadRequestException);
expect(userMock.get).toHaveBeenCalledWith('user-3');
expect(userMock.get).toHaveBeenCalledWith('user-3', {});
expect(albumMock.create).not.toHaveBeenCalled();
});
});
+2 -2
View File
@@ -95,7 +95,7 @@ export class AlbumService {
async create(authUser: AuthUserDto, dto: CreateAlbumDto): Promise<AlbumResponseDto> {
for (const userId of dto.sharedWithUserIds || []) {
const exists = await this.userRepository.get(userId);
const exists = await this.userRepository.get(userId, {});
if (!exists) {
throw new BadRequestException('User not found');
}
@@ -238,7 +238,7 @@ export class AlbumService {
throw new BadRequestException('User already added');
}
const user = await this.userRepository.get(userId);
const user = await this.userRepository.get(userId, {});
if (!user) {
throw new BadRequestException('User not found');
}