Skip to content

Commit

Permalink
Merge pull request #138 from modern-agile-team/feature/socket
Browse files Browse the repository at this point in the history
Modify(hobiJeong/socket) Guard 수정
  • Loading branch information
hobiJeong authored Nov 16, 2023
2 parents 7da2fe4 + 1fb7982 commit 138f84e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/chat/controllers/chat.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { ApiGetChatNotifications } from '../swagger-decorators/get-chat-notifica
import { ApiCreateChatImage } from '../swagger-decorators/create-chat-image.decorators';

@ApiTags('CHAT')
@UseGuards(JwtAccessTokenGuard)
@UsePipes(ValidationPipe)
@Controller('chat-room')
export class ChatController {
Expand All @@ -48,12 +47,14 @@ export class ChatController {
return this.chatService.notificationListener();
}

@UseGuards(JwtAccessTokenGuard)
@ApiGetChatRooms()
@Get()
async getChatRooms(@GetUserId() userId: number) {
return this.chatService.getChatRooms(userId);
}

@UseGuards(JwtAccessTokenGuard)
@ApiGetOneChatRoom()
@Get(':roomId')
async getOneChatRoom(
Expand All @@ -63,6 +64,7 @@ export class ChatController {
return this.chatService.getOneChatRoom(userId, roomId);
}

@UseGuards(JwtAccessTokenGuard)
@ApiCreateChatRoom()
@Post()
async createChatRoom(
Expand All @@ -72,6 +74,7 @@ export class ChatController {
return this.chatService.createChatRoom(userId, body.receiverId);
}

@UseGuards(JwtAccessTokenGuard)
@ApiDeleteChatRoom()
@Delete(':roomId')
async deleteChatRoom(
Expand All @@ -81,6 +84,7 @@ export class ChatController {
return this.chatService.deleteChatRoom(userId, roomId);
}

@UseGuards(JwtAccessTokenGuard)
@ApiGetChats()
@Get(':roomId/chat')
async getChats(
Expand All @@ -90,6 +94,7 @@ export class ChatController {
return this.chatService.getChats(userId, roomId);
}

@UseGuards(JwtAccessTokenGuard)
@ApiCreateChatImage()
@Post(':roomId/chat/image')
@UseInterceptors(FileInterceptor('file'))
Expand All @@ -107,6 +112,7 @@ export class ChatController {
);
}

@UseGuards(JwtAccessTokenGuard)
@ApiGetChatNotifications()
@Get('chat/notice')
async getChatNotifications(
Expand Down
10 changes: 3 additions & 7 deletions src/chat/services/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ export class ChatService {
) {}

notificationListener() {
return (
this.subject
.asObservable()
.pipe(
map((notification: Notification) => JSON.stringify(notification)),
),
return this.subject.asObservable().pipe(
map((notification: Notification) => JSON.stringify(notification)),
catchError((err) => {
this.logger.error('notificationListener : ' + err.message);
throw new HttpException(err.message, HttpStatus.INTERNAL_SERVER_ERROR);
})
}),
);
}
async getChatRooms(myId: number) {
Expand Down

0 comments on commit 138f84e

Please sign in to comment.