Skip to content

Commit

Permalink
Merge pull request #375 from boostcampwm2023/BE-feature/spaces
Browse files Browse the repository at this point in the history
ν…ŒμŠ€νŠΈ 블둝화, νƒ€μž… μˆ˜μ •
  • Loading branch information
Conut-1 authored Dec 30, 2024
2 parents 5bdf581 + aebc8c4 commit c3e5a4c
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export class IsProfileInSpaceGuard implements CanActivate {

async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const profileUuid = request.body.profile_uuid || request.query.profile_uuid;
const profileUuid =
request.body.profile_uuid ||
request.query.profile_uuid ||
request.params.profile_uuid;
const spaceUuid = request.params.space_uuid;
if (!profileUuid || !spaceUuid) throw new BadRequestException();
const isProfileInSpace = await this.profileSpaceService.isProfileInSpace(
Expand Down
5 changes: 4 additions & 1 deletion nestjs-BE/server/src/auth/guards/match-user-profile.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export class MatchUserProfileGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const userUuid = request.user.uuid;
const profileUuid = request.body.profile_uuid || request.query.profile_uuid;
const profileUuid =
request.body.profile_uuid ||
request.query.profile_uuid ||
request.params.profile_uuid;
if (!profileUuid || !userUuid) throw new BadRequestException();
const profile =
await this.profilesService.findProfileByProfileUuid(profileUuid);
Expand Down
3 changes: 2 additions & 1 deletion nestjs-BE/server/src/spaces/dto/create-space.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class CreateSpaceDto {
@ApiProperty({
example: 'space-icon.png',
description: 'Profile icon for the space',
required: false,
})
icon: string;
icon: Express.Multer.File;
}
7 changes: 3 additions & 4 deletions nestjs-BE/server/src/spaces/dto/update-space.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ export class UpdateSpaceDto {
})
name: string;

@IsOptional()
@ApiProperty({
example: 'new image',
description: 'Updated space icon',
example: 'space-icon.png',
description: 'New space icon to change',
required: false,
})
icon: string;
icon: Express.Multer.File;
}
6 changes: 2 additions & 4 deletions nestjs-BE/server/src/spaces/spaces.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ export class SpacesService {
icon: Express.Multer.File,
updateSpaceDto: UpdateSpaceDto,
): Promise<Space> {
const updateData: Partial<UpdateSpaceDto> = omit(updateSpaceDto, [
'icon',
'profileUuid',
]);
const updateData: Partial<Pick<UpdateSpaceDto, 'name'> & { icon: string }> =
omit(updateSpaceDto, ['icon', 'profileUuid']);
if (icon) {
updateData.icon = await this.uploadService.uploadFile(icon);
}
Expand Down
Loading

0 comments on commit c3e5a4c

Please sign in to comment.